123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666 |
- using UnityEngine;
- using UnityEngine.Assertions;
- using UnityEditor;
- using UnityEditorInternal;
- using System;
- using System.IO;
- using System.Collections;
- using System.Collections.Generic;
- namespace VoxelImporter
- {
- [CustomEditor(typeof(VoxelChunksObject))]
- public class VoxelChunksObjectEditor : VoxelBaseEditor
- {
- public VoxelChunksObject objectTarget { get; protected set; }
- public VoxelChunksObjectCore objectCore { get; protected set; }
- #region strings
- private static string[] SplitModeQBStrings =
- {
- "Chunk Size",
- "Qubicle Matrix",
- };
- private static string[] SplitModeVOXStrings =
- {
- "Chunk Size",
- "MagicaVoxel World Editor",
- };
- private static string[] SplitModeDefaultStrings =
- {
- "Chunk Size",
- };
- #endregion
- protected override void OnEnable()
- {
- base.OnEnable();
- objectTarget = target as VoxelChunksObject;
- if (objectTarget == null) return;
- baseCore = objectCore = new VoxelChunksObjectCore(objectTarget);
- OnEnableInitializeSet();
- }
- protected override void InspectorGUI()
- {
- base.InspectorGUI();
- #if UNITY_2018_3_OR_NEWER
- {
- if (prefabType == PrefabAssetType.Regular && !baseCore.isPrefabEditMode)
- {
- EditorGUI.BeginDisabledGroup(true);
- }
- }
- #endif
- Action<UnityEngine.Object, string> TypeTitle = (o, title) =>
- {
- if (o == null)
- EditorGUILayout.LabelField(title, guiStyleMagentaBold);
- else if (prefabEnable && !AssetDatabase.Contains(o))
- EditorGUILayout.LabelField(title, guiStyleRedBold);
- else
- EditorGUILayout.LabelField(title, EditorStyles.boldLabel);
- };
- InspectorGUI_Import();
- #region Object
- if (!string.IsNullOrEmpty(baseTarget.voxelFilePath))
- {
- //Object
- baseTarget.edit_objectFoldout = EditorGUILayout.Foldout(baseTarget.edit_objectFoldout, "Object", guiStyleFoldoutBold);
- if (baseTarget.edit_objectFoldout)
- {
- EditorGUI.BeginDisabledGroup(isPrefab);
- EditorGUILayout.BeginVertical(GUI.skin.box);
- #region Mesh
- if (baseTarget.advancedMode)
- {
- EditorGUILayout.LabelField("Mesh", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- InspectorGUI_Object_Mesh_Settings();
- EditorGUI.indentLevel--;
- }
- #endregion
- #region Material
- {
- if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
- {
- if (objectTarget.materials == null || objectTarget.materials.Count == 0)
- EditorGUILayout.LabelField("Material", guiStyleMagentaBold);
- else if (prefabEnable)
- {
- bool contains = true;
- for (int i = 0; i < objectTarget.materials.Count; i++)
- {
- if (objectTarget.materials[i] == null || !AssetDatabase.Contains(objectTarget.materials[i]))
- {
- contains = false;
- break;
- }
- }
- EditorGUILayout.LabelField("Material", contains ? EditorStyles.boldLabel : guiStyleRedBold);
- }
- else
- EditorGUILayout.LabelField("Material", EditorStyles.boldLabel);
- }
- else
- {
- EditorGUILayout.LabelField("Material", EditorStyles.boldLabel);
- }
- EditorGUI.indentLevel++;
- #region updateMeshRendererMaterials
- if (baseTarget.advancedMode)
- {
- EditorGUI.BeginChangeCheck();
- var updateMeshRendererMaterials = EditorGUILayout.ToggleLeft("Update the Mesh Renderer Materials", baseTarget.updateMeshRendererMaterials);
- if (EditorGUI.EndChangeCheck())
- {
- if (EditorUtility.DisplayDialog("Update the Mesh Renderer Materials", "It will be changed.\nAre you sure?", "ok", "cancel"))
- {
- UndoRecordObject("Inspector");
- baseTarget.updateMeshRendererMaterials = updateMeshRendererMaterials;
- baseCore.SetRendererCompornent();
- }
- }
- }
- #endregion
- #region Material Mode
- if (baseTarget.advancedMode)
- {
- EditorGUI.BeginChangeCheck();
- var materialMode = (VoxelChunksObject.MaterialMode)EditorGUILayout.EnumPopup("Material Mode", objectTarget.materialMode);
- if (EditorGUI.EndChangeCheck())
- {
- UndoRecordObject("Inspector");
- {
- var chunkObjects = objectTarget.chunks;
- if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
- {
- objectTarget.materials = null;
- objectTarget.atlasTexture = null;
- }
- else if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Individual)
- {
- for (int i = 0; i < chunkObjects.Length; i++)
- {
- if (chunkObjects[i] == null) continue;
- chunkObjects[i].materials = null;
- chunkObjects[i].atlasTexture = null;
- }
- }
- }
- objectTarget.materialMode = materialMode;
- Refresh();
- }
- }
- #endregion
- if (materialList != null)
- {
- materialList.DoLayoutList();
- }
- InspectorGUI_ConfigureMaterial();
- EditorGUI.indentLevel--;
- }
- #endregion
- #region Texture
- if (baseTarget.advancedMode)
- {
- if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
- TypeTitle(objectTarget.atlasTexture, "Texture");
- else
- EditorGUILayout.LabelField("Texture", EditorStyles.boldLabel);
- EditorGUI.indentLevel++;
- #region updateMaterialTexture
- {
- EditorGUI.BeginChangeCheck();
- var updateMaterialTexture = EditorGUILayout.ToggleLeft("Update the Material Texture", baseTarget.updateMaterialTexture);
- if (EditorGUI.EndChangeCheck())
- {
- if (EditorUtility.DisplayDialog("Update the Material Texture", "It will be changed.\nAre you sure?", "ok", "cancel"))
- {
- UndoRecordObject("Inspector");
- baseTarget.updateMaterialTexture = updateMaterialTexture;
- baseCore.SetRendererCompornent();
- }
- }
- }
- #endregion
- #region Texture
- if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
- {
- EditorGUILayout.BeginHorizontal();
- {
- EditorGUI.BeginDisabledGroup(true);
- EditorGUILayout.ObjectField(objectTarget.atlasTexture, typeof(Texture2D), false);
- EditorGUI.EndDisabledGroup();
- }
- if (objectTarget.atlasTexture != null)
- {
- if (!IsMainAsset(objectTarget.atlasTexture))
- {
- if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16)))
- {
- #region Create Texture
- string path = EditorUtility.SaveFilePanel("Save atlas texture", baseCore.GetDefaultPath(), string.Format("{0}_tex.png", baseTarget.gameObject.name), "png");
- if (!string.IsNullOrEmpty(path))
- {
- if (path.IndexOf(Application.dataPath) < 0)
- {
- SaveInsideAssetsFolderDisplayDialog();
- }
- else
- {
- UndoRecordObject("Save Atlas Texture");
- File.WriteAllBytes(path, objectTarget.atlasTexture.EncodeToPNG());
- path = path.Replace(Application.dataPath, "Assets");
- AssetDatabase.ImportAsset(path);
- objectCore.SetTextureImporterSetting(path, objectTarget.atlasTexture);
- objectTarget.atlasTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
- Refresh();
- }
- }
- #endregion
- }
- }
- {
- if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16)))
- {
- #region Reset Texture
- UndoRecordObject("Reset Atlas Texture");
- objectTarget.atlasTexture = null;
- Refresh();
- #endregion
- }
- }
- }
- EditorGUILayout.EndHorizontal();
- }
- #endregion
- #region Generate Mip Maps
- {
- EditorGUI.BeginChangeCheck();
- var generateMipMaps = EditorGUILayout.Toggle("Generate Mip Maps", baseTarget.generateMipMaps);
- if (EditorGUI.EndChangeCheck())
- {
- UndoRecordObject("Inspector");
- baseTarget.generateMipMaps = generateMipMaps;
- Refresh();
- }
- }
- #endregion
- #region Texture Size
- if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
- {
- EditorGUILayout.LabelField("Texture Size", objectTarget.atlasTexture != null ? string.Format("{0} x {1}", objectTarget.atlasTexture.width, objectTarget.atlasTexture.height) : "");
- }
- #endregion
- EditorGUI.indentLevel--;
- }
- #endregion
- EditorGUILayout.EndVertical();
- EditorGUI.EndDisabledGroup();
- }
- }
- #endregion
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUI.BeginDisabledGroup(isPrefab);
- InspectorGUI_Refresh();
- #region Refresh all chunks
- if (GUILayout.Button(new GUIContent("Refresh all chunks", "This will be created completely from Chunk's GameObject again.\nInformation maintained in normal Refresh will also be updated.")))
- {
- UndoRecordObject("Inspector", true);
- Refresh();
- }
- #endregion
- EditorGUI.EndDisabledGroup();
- EditorGUILayout.EndHorizontal();
- }
- #if UNITY_2018_3_OR_NEWER
- {
- if (prefabType == PrefabAssetType.Regular && !baseCore.isPrefabEditMode)
- {
- EditorGUI.EndDisabledGroup();
- }
- }
- #endif
- }
- protected override void UndoRecordObject(string text, bool reset = false)
- {
- base.UndoRecordObject(text);
- for (int i = 0; i < objectTarget.chunks.Length; i++)
- {
- if (objectTarget.chunks[i] == null) continue;
- Undo.RecordObject(objectTarget.chunks[i], text);
- }
- if (reset)
- {
- objectCore.RemoveAllChunk();
- }
- }
- protected override void InspectorGUI_ImportSettingsImportScaleVector()
- {
- EditorGUI.BeginChangeCheck();
- var importScale = EditorGUILayout.Vector3Field("Import Scale", objectTarget.edit_importScale);
- if (EditorGUI.EndChangeCheck())
- {
- InspectorGUI_ImportSettingsImportScale_Set(importScale);
- }
- }
- protected override void InspectorGUI_ImportSettingsImportScale_Set(Vector3 scale)
- {
- UndoRecordObject("Inspector");
- objectTarget.edit_importScale = scale;
- }
- protected override void InspectorGUI_ImportSettingsImportOffset()
- {
- EditorGUI.BeginChangeCheck();
- var importOffset = EditorGUILayout.Vector3Field("Import Offset", objectTarget.edit_importOffset);
- if (EditorGUI.EndChangeCheck())
- {
- UndoRecordObject("Inspector");
- objectTarget.edit_importOffset = importOffset;
- }
- }
- protected override void InspectorGUI_ImportSettingsExtra()
- {
- #region Split Mode
- {
- EditorGUI.BeginChangeCheck();
- int splitMode = 0;
- switch (objectTarget.fileType)
- {
- case VoxelBase.FileType.vox:
- splitMode = EditorGUILayout.Popup("Split Mode", objectTarget.splitMode == VoxelChunksObject.SplitMode.ChunkSize ? 0 : 1, SplitModeVOXStrings);
- break;
- case VoxelBase.FileType.qb:
- splitMode = EditorGUILayout.Popup("Split Mode", objectTarget.splitMode == VoxelChunksObject.SplitMode.ChunkSize ? 0 : 1, SplitModeQBStrings);
- break;
- default:
- splitMode = EditorGUILayout.Popup("Split Mode", objectTarget.splitMode == VoxelChunksObject.SplitMode.ChunkSize ? 0 : 1, SplitModeDefaultStrings);
- break;
- }
- if (EditorGUI.EndChangeCheck())
- {
- UndoRecordObject("Inspector", true);
- if (splitMode == 0)
- objectTarget.splitMode = VoxelChunksObject.SplitMode.ChunkSize;
- else
- objectTarget.splitMode = VoxelChunksObject.SplitMode.QubicleMatrix;
- Refresh();
- }
- }
- #endregion
- {
- EditorGUI.indentLevel++;
- #region Chunk Size
- if (objectTarget.splitMode == VoxelChunksObject.SplitMode.ChunkSize)
- {
- EditorGUI.BeginChangeCheck();
- var chunkSize = EditorGUILayout.Vector3Field("Chunk Size", new Vector3(objectTarget.edit_chunkSize.x, objectTarget.edit_chunkSize.y, objectTarget.edit_chunkSize.z));
- if (EditorGUI.EndChangeCheck())
- {
- UndoRecordObject("Inspector");
- objectTarget.edit_chunkSize.x = Mathf.RoundToInt(chunkSize.x);
- objectTarget.edit_chunkSize.y = Mathf.RoundToInt(chunkSize.y);
- objectTarget.edit_chunkSize.z = Mathf.RoundToInt(chunkSize.z);
- }
- }
- #endregion
- EditorGUI.indentLevel--;
- }
- #region Create contact faces of chunks
- if (baseTarget.advancedMode)
- {
- EditorGUI.BeginChangeCheck();
- var createContactChunkFaces = EditorGUILayout.Toggle("Create contact faces of chunks", objectTarget.createContactChunkFaces);
- if (EditorGUI.EndChangeCheck())
- {
- UndoRecordObject("Inspector");
- objectTarget.createContactChunkFaces = createContactChunkFaces;
- Refresh();
- }
- }
- #endregion
- #region Changed
- {
- if (objectTarget.IsEditorChanged())
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Change Settings", guiStyleRedBold);
- EditorGUILayout.Space();
- if (GUILayout.Button("Revert", GUILayout.Width(64f)))
- {
- UndoRecordObject("Inspector");
- objectTarget.RevertEditorParam();
- }
- if (GUILayout.Button("Apply", GUILayout.Width(64f)))
- {
- UndoRecordObject("Inspector", true);
- objectTarget.ApplyEditorParam();
- Refresh();
- }
- EditorGUILayout.EndHorizontal();
- }
- }
- #endregion
- }
- protected override void Refresh()
- {
- base.Refresh();
- objectTarget.RevertEditorParam();
- }
- protected override List<Material> GetMaterialListMaterials()
- {
- return objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine ? objectTarget.materials : null;
- }
- [MenuItem("CONTEXT/VoxelChunksObject/Save All Unsaved Assets")]
- private static void ContextSaveAllUnsavedAssets(MenuCommand menuCommand)
- {
- var objectTarget = menuCommand.context as VoxelChunksObject;
- if (objectTarget == null) return;
- var objectCore = new VoxelChunksObjectCore(objectTarget);
- var folder = EditorUtility.OpenFolderPanel("Save all", objectCore.GetDefaultPath(), null);
- if (string.IsNullOrEmpty(folder)) return;
- if (folder.IndexOf(Application.dataPath) < 0)
- {
- SaveInsideAssetsFolderDisplayDialog();
- return;
- }
- Undo.RecordObject(objectTarget, "Save All Unsaved Assets");
- if (objectTarget.chunks != null)
- Undo.RecordObjects(objectTarget.chunks, "Save All Unsaved Assets");
- if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Combine)
- {
- #region Material
- if (objectTarget.materials != null)
- {
- for (int index = 0; index < objectTarget.materials.Count; index++)
- {
- if (objectTarget.materials[index] == null || IsMainAsset(objectTarget.materials[index])) continue;
- var path = folder + "/" + string.Format("{0}_mat{1}.mat", objectTarget.gameObject.name, index);
- path = path.Replace(Application.dataPath, "Assets");
- path = AssetDatabase.GenerateUniqueAssetPath(path);
- AssetDatabase.CreateAsset(Material.Instantiate(objectTarget.materials[index]), path);
- objectTarget.materials[index] = AssetDatabase.LoadAssetAtPath<Material>(path);
- }
- }
- #endregion
- #region Texture
- if (objectTarget.atlasTexture != null && !IsMainAsset(objectTarget.atlasTexture))
- {
- var path = folder + "/" + string.Format("{0}_tex.png", objectTarget.gameObject.name);
- {
- path = AssetDatabase.GenerateUniqueAssetPath(path.Replace(Application.dataPath, "Assets"));
- path = (Application.dataPath + path).Replace("AssetsAssets", "Assets");
- }
- File.WriteAllBytes(path, objectTarget.atlasTexture.EncodeToPNG());
- path = path.Replace(Application.dataPath, "Assets");
- AssetDatabase.ImportAsset(path);
- objectCore.SetTextureImporterSetting(path, objectTarget.atlasTexture);
- objectTarget.atlasTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
- }
- #endregion
- if (objectTarget.chunks != null)
- {
- for (int i = 0; i < objectTarget.chunks.Length; i++)
- {
- if (objectTarget.chunks[i] == null) continue;
- #region Mesh
- if (objectTarget.chunks[i].mesh != null && !IsMainAsset(objectTarget.chunks[i].mesh))
- {
- var path = folder + "/" + string.Format("{0}_{1}_mesh.asset", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName);
- path = path.Replace(Application.dataPath, "Assets");
- path = AssetDatabase.GenerateUniqueAssetPath(path);
- AssetDatabase.CreateAsset(Mesh.Instantiate(objectTarget.chunks[i].mesh), path);
- objectTarget.chunks[i].mesh = AssetDatabase.LoadAssetAtPath<Mesh>(path);
- }
- #endregion
- }
- }
- }
- else if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Individual)
- {
- if (objectTarget.chunks != null)
- {
- for (int i = 0; i < objectTarget.chunks.Length; i++)
- {
- if (objectTarget.chunks[i] == null) continue;
- #region Mesh
- if (objectTarget.chunks[i].mesh != null && !IsMainAsset(objectTarget.chunks[i].mesh))
- {
- var path = folder + "/" + string.Format("{0}_{1}_mesh.asset", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName);
- path = path.Replace(Application.dataPath, "Assets");
- path = AssetDatabase.GenerateUniqueAssetPath(path);
- AssetDatabase.CreateAsset(Mesh.Instantiate(objectTarget.chunks[i].mesh), path);
- objectTarget.chunks[i].mesh = AssetDatabase.LoadAssetAtPath<Mesh>(path);
- }
- #endregion
- #region Material
- if (objectTarget.chunks[i].materials != null)
- {
- for (int index = 0; index < objectTarget.chunks[i].materials.Count; index++)
- {
- if (objectTarget.chunks[i].materials[index] == null || IsMainAsset(objectTarget.chunks[i].materials[index])) continue;
- var path = folder + "/" + string.Format("{0}_{1}_mat{2}.mat", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName, index);
- path = path.Replace(Application.dataPath, "Assets");
- path = AssetDatabase.GenerateUniqueAssetPath(path);
- AssetDatabase.CreateAsset(Material.Instantiate(objectTarget.chunks[i].materials[index]), path);
- objectTarget.chunks[i].materials[index] = AssetDatabase.LoadAssetAtPath<Material>(path);
- }
- }
- #endregion
- #region Texture
- if (objectTarget.chunks[i].atlasTexture != null && !IsMainAsset(objectTarget.chunks[i].atlasTexture))
- {
- var path = folder + "/" + string.Format("{0}_{1}_tex.png", objectTarget.gameObject.name, objectTarget.chunks[i].chunkName);
- {
- path = AssetDatabase.GenerateUniqueAssetPath(path.Replace(Application.dataPath, "Assets"));
- path = (Application.dataPath + path).Replace("AssetsAssets", "Assets");
- }
- File.WriteAllBytes(path, objectTarget.chunks[i].atlasTexture.EncodeToPNG());
- path = path.Replace(Application.dataPath, "Assets");
- AssetDatabase.ImportAsset(path);
- objectCore.SetTextureImporterSetting(path, objectTarget.chunks[i].atlasTexture);
- objectTarget.chunks[i].atlasTexture = AssetDatabase.LoadAssetAtPath<Texture2D>(path);
- }
- #endregion
- }
- }
- }
- else
- {
- Assert.IsTrue(false);
- }
- objectCore.ReCreate();
- InternalEditorUtility.RepaintAllViews();
- }
- [MenuItem("CONTEXT/VoxelChunksObject/Reset All Assets")]
- private static void ResetAllSavedAssets(MenuCommand menuCommand)
- {
- var objectTarget = menuCommand.context as VoxelChunksObject;
- if (objectTarget == null) return;
- var objectCore = new VoxelChunksObjectCore(objectTarget);
- Undo.RecordObject(objectTarget, "Reset All Assets");
- if (objectTarget.chunks != null)
- Undo.RecordObjects(objectTarget.chunks, "Save All Unsaved Assets");
- #region Material
- if (objectTarget.materials != null)
- {
- for (int i = 0; i < objectTarget.materials.Count; i++)
- {
- if (!IsMainAsset(objectTarget.materials[i]))
- objectTarget.materials[i] = null;
- else
- objectTarget.materials[i] = Instantiate<Material>(objectTarget.materials[i]);
- }
- }
- #endregion
- #region Texture
- objectTarget.atlasTexture = null;
- #endregion
- if (objectTarget.chunks != null)
- {
- for (int i = 0; i < objectTarget.chunks.Length; i++)
- {
- if (objectTarget.chunks[i] == null) continue;
- objectTarget.chunks[i].mesh = null;
- #region Material
- if (objectTarget.chunks[i].materials != null)
- {
- for (int j = 0; j < objectTarget.chunks[i].materials.Count; j++)
- {
- if (!IsMainAsset(objectTarget.chunks[i].materials[j]))
- objectTarget.chunks[i].materials[j] = null;
- else
- objectTarget.chunks[i].materials[j] = Instantiate<Material>(objectTarget.chunks[i].materials[j]);
- }
- }
- #endregion
- objectTarget.chunks[i].atlasTexture = null;
- }
- }
- objectCore.ReCreate();
- InternalEditorUtility.RepaintAllViews();
- }
- [MenuItem("CONTEXT/VoxelChunksObject/Export COLLADA(dae) File", false, 10000)]
- private static void ExportDaeFile(MenuCommand menuCommand)
- {
- var objectTarget = menuCommand.context as VoxelChunksObject;
- if (objectTarget == null) return;
- var objectCore = new VoxelChunksObjectCore(objectTarget);
- string path = EditorUtility.SaveFilePanel("Export COLLADA(dae) File", objectCore.GetDefaultPath(), string.Format("{0}.dae", Path.GetFileNameWithoutExtension(objectTarget.voxelFilePath)), "dae");
- if (string.IsNullOrEmpty(path)) return;
- if (!objectCore.ExportDaeFile(path))
- {
- Debug.LogErrorFormat("<color=green>[Voxel Importer]</color> Export COLLADA(dae) File error. file:{0}", path);
- }
- }
- [MenuItem("CONTEXT/VoxelChunksObject/Export COLLADA(dae) File", true)]
- private static bool IsValidateExportDaeFile(MenuCommand menuCommand)
- {
- var objectTarget = menuCommand.context as VoxelChunksObject;
- if (objectTarget == null) return false;
- #if UNITY_2018_3_OR_NEWER
- return true;
- #else
- return PrefabUtility.GetPrefabType(objectTarget) != PrefabType.Prefab;
- #endif
- }
- [MenuItem("CONTEXT/VoxelChunksObject/Remove All Voxel Importer Compornent", false, 10100)]
- private static void RemoveAllVoxelImporterCompornent(MenuCommand menuCommand)
- {
- var objectTarget = menuCommand.context as VoxelChunksObject;
- if (objectTarget == null) return;
- if (objectTarget.chunks != null)
- {
- for (int i = 0; i < objectTarget.chunks.Length; i++)
- {
- Undo.DestroyObjectImmediate(objectTarget.chunks[i]);
- }
- }
- Undo.DestroyObjectImmediate(objectTarget);
- }
- }
- }
|