public override void ResetAllAssets() { #region Material if (voxelObject.materials != null) { for (int i = 0; i < voxelObject.materials.Count; i++) { if (voxelObject.materials[i] == null) { continue; } voxelObject.materials[i] = EditorCommon.ResetMaterial(voxelObject.materials[i]); } } #endregion #region Texture voxelObject.atlasTexture = null; #endregion #region Mesh voxelObject.mesh = null; if (voxelObject.frames != null) { for (int i = 0; i < voxelObject.frames.Count; i++) { voxelObject.frames[i].mesh = null; } } #endregion #region Structure voxelObject.voxelStructure = null; #endregion }
public override void ResetAllAssets() { #region Material if (voxelObject.materials != null) { for (int i = 0; i < voxelObject.materials.Count; i++) { if (voxelObject.materials[i] == null) { continue; } voxelObject.materials[i] = EditorCommon.ResetMaterial(voxelObject.materials[i]); } } #endregion #region Texture voxelObject.atlasTexture = null; #endregion if (voxelObject.chunks != null) { for (int i = 0; i < voxelObject.chunks.Length; i++) { if (voxelObject.chunks[i] == null) { continue; } voxelObject.chunks[i].mesh = null; #region Material if (voxelObject.chunks[i].materials != null) { for (int j = 0; j < voxelObject.chunks[i].materials.Count; j++) { if (voxelObject.chunks[i].materials[j] == null) { continue; } voxelObject.chunks[i].materials[j] = EditorCommon.ResetMaterial(voxelObject.chunks[i].materials[j]); } } #endregion voxelObject.chunks[i].atlasTexture = null; } } #region Structure voxelObject.voxelStructure = null; #endregion }
public override void ResetAllAssets() { #region Mesh if (explosionObject.chunksExplosion != null) { for (int i = 0; i < explosionObject.chunksExplosion.Length; i++) { if (explosionObject.chunksExplosion[i] == null) { continue; } explosionObject.chunksExplosion[i].meshes = null; if (explosionObject.chunksExplosion[i].materials == null) { continue; } for (int j = 0; j < explosionObject.chunksExplosion[i].materials.Count; j++) { if (explosionObject.chunksExplosion[i].materials[j] == null) { continue; } explosionObject.chunksExplosion[i].materials[j] = EditorCommon.ResetMaterial(explosionObject.chunksExplosion[i].materials[j]); } } } #endregion #region Material if (explosionObject.materials != null) { for (int i = 0; i < explosionObject.materials.Count; i++) { if (explosionObject.materials[i] == null) { continue; } explosionObject.materials[i] = EditorCommon.ResetMaterial(explosionObject.materials[i]); } } #endregion }
public override void ResetAllAssets() { #region Mesh explosionObject.meshes = null; #endregion #region Material if (explosionObject.materials != null) { for (int i = 0; i < explosionObject.materials.Count; i++) { if (explosionObject.materials[i] == null) { continue; } explosionObject.materials[i] = EditorCommon.ResetMaterial(explosionObject.materials[i]); } } #endregion }
protected override void Inspector_MeshMaterial() { #region Mesh { EditorGUILayout.LabelField("Mesh", EditorStyles.boldLabel); { EditorGUI.indentLevel++; { if (explosionObject.meshes != null) { for (int i = 0; i < explosionObject.meshes.Count; i++) { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(explosionObject.meshes[i].mesh, typeof(Mesh), false); EditorGUI.EndDisabledGroup(); } if (explosionObject.meshes[i] != null && explosionObject.meshes[i].mesh != null) { if (!EditorCommon.IsMainAsset(explosionObject.meshes[i].mesh)) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Mesh var index = i; EditorApplication.delayCall += () => { string path = EditorUtility.SaveFilePanel("Save mesh", explosionCore.voxelBaseCore.GetDefaultPath(), string.Format("{0}_explosion_mesh{1}.asset", explosionObject.gameObject.name, index), "asset"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(explosionObject, "Save Mesh"); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(Mesh.Instantiate(explosionObject.meshes[index].mesh), path); explosionObject.meshes[index].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path); explosionCore.Generate(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Mesh Undo.RecordObject(explosionObject, "Reset Mesh"); explosionObject.meshes[i].mesh = null; explosionCore.Generate(); #endregion } } } EditorGUILayout.EndHorizontal(); } } } EditorGUI.indentLevel--; } } #endregion #region Material { EditorGUILayout.LabelField("Material", EditorStyles.boldLabel); { EditorGUI.indentLevel++; { if (explosionObject.materials != null) { for (int i = 0; i < explosionObject.materials.Count; i++) { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(explosionObject.materials[i], typeof(Material), false); EditorGUI.EndDisabledGroup(); } if (explosionObject.materials[i] != null) { if (!EditorCommon.IsMainAsset(explosionObject.materials[i])) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Material var index = i; EditorApplication.delayCall += () => { string path = EditorUtility.SaveFilePanel("Save material", explosionCore.voxelBaseCore.GetDefaultPath(), string.Format("{0}_explosion_mat{1}.mat", explosionObject.gameObject.name, index), "mat"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(explosionObject, "Save Material"); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(Material.Instantiate(explosionObject.materials[index]), path); explosionObject.materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path); explosionCore.Generate(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Material Undo.RecordObject(explosionObject, "Reset Material"); explosionObject.materials[i] = EditorCommon.ResetMaterial(explosionObject.materials[i]); explosionCore.Generate(); #endregion } } } EditorGUILayout.EndHorizontal(); } } } EditorGUI.indentLevel--; } } #endregion }
protected void InspectorGUI() { #region Object { explosionObject.edit_objectFoldout = EditorGUILayout.Foldout(explosionObject.edit_objectFoldout, "Object", guiStyleFoldoutBold); if (explosionObject.edit_objectFoldout) { EditorGUILayout.BeginVertical(guiStyleSkinBox); #region Mesh { EditorGUILayout.LabelField("Mesh", EditorStyles.boldLabel); EditorGUI.indentLevel++; #region Mesh if (explosionObject.meshes != null) { for (int i = 0; i < explosionObject.meshes.Count; i++) { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(explosionObject.meshes[i].mesh, typeof(Mesh), false); EditorGUI.EndDisabledGroup(); } if (explosionObject.meshes[i].mesh != null) { if (!EditorCommon.IsMainAsset(explosionObject.meshes[i].mesh)) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Mesh var index = i; EditorApplication.delayCall += () => { string path = EditorUtility.SaveFilePanel("Save mesh", chunkCore.GetDefaultPath(), string.Format("{0}_{1}_explosion_mesh{2}.asset", voxelObject.gameObject.name, chunkObject.chunkName, index), "asset"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(explosionObject, "Save Mesh"); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(Mesh.Instantiate(explosionObject.meshes[index].mesh), path); explosionObject.meshes[index].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path); voxelExplosionCore.Generate(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Mesh Undo.RecordObject(voxelExplosionObject, "Reset Mesh"); Undo.RecordObjects(voxelExplosionObject.chunksExplosion, "Reset Mesh"); explosionObject.meshes[i].mesh = null; voxelExplosionCore.Generate(); #endregion } } } EditorGUILayout.EndHorizontal(); } } #endregion EditorGUI.indentLevel--; } #endregion #region Material if (voxelObject.materialMode == VoxelChunksObject.MaterialMode.Individual) { EditorGUILayout.LabelField("Material", EditorStyles.boldLabel); EditorGUI.indentLevel++; #region Material for (int i = 0; i < explosionObject.materials.Count; i++) { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(explosionObject.materials[i], typeof(Material), false); EditorGUI.EndDisabledGroup(); } if (explosionObject.materials[i] != null) { if (!EditorCommon.IsMainAsset(explosionObject.materials[i])) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Material var index = i; EditorApplication.delayCall += () => { string defaultName = string.Format("{0}_{1}_explosion_mat{2}.mat", voxelObject.gameObject.name, chunkObject.chunkName, index); string path = EditorUtility.SaveFilePanel("Save material", chunkCore.GetDefaultPath(), defaultName, "mat"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(explosionObject, "Save Material"); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(Material.Instantiate(explosionObject.materials[index]), path); explosionObject.materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path); voxelExplosionCore.Generate(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Material Undo.RecordObject(voxelExplosionObject, "Reset Material"); Undo.RecordObjects(voxelExplosionObject.chunksExplosion, "Reset Material"); explosionObject.materials[i] = EditorCommon.ResetMaterial(explosionObject.materials[i]); voxelExplosionCore.Generate(); #endregion } } } EditorGUILayout.EndHorizontal(); } #endregion EditorGUI.indentLevel--; } #endregion EditorGUILayout.EndVertical(); } } #endregion #region Generate { if (GUILayout.Button("Generate")) { Undo.RecordObject(voxelExplosionObject, "Generate Voxel Explosion"); Undo.RecordObjects(voxelExplosionObject.chunksExplosion, "Generate Voxel Explosion"); voxelExplosionCore.Generate(); } } #endregion }
protected void InspectorGUI() { #region Simple { EditorGUI.BeginChangeCheck(); var mode = GUILayout.Toolbar(objectTarget.advancedMode ? 1 : 0, VoxelBaseEditor.Edit_AdvancedModeStrings); if (EditorGUI.EndChangeCheck()) { objectTarget.advancedMode = mode != 0 ? true : false; } } #endregion EditorGUILayout.Space(); { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Reset Transform")) { Undo.RecordObject(chunkTarget.transform, "Reset Chunk Transform"); chunkTarget.transform.localPosition = chunkTarget.basicOffset; chunkTarget.transform.localRotation = Quaternion.identity; chunkTarget.transform.localScale = Vector3.one; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } #region Object if (objectTarget.advancedMode) { chunkTarget.edit_objectFoldout = EditorGUILayout.Foldout(chunkTarget.edit_objectFoldout, "Object", guiStyleFoldoutBold); if (chunkTarget.edit_objectFoldout) { EditorGUILayout.BeginVertical(guiStyleSkinBox); #region Mesh { EditorGUILayout.LabelField("Mesh", EditorStyles.boldLabel); EditorGUI.indentLevel++; #region Mesh { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(chunkTarget.mesh, typeof(Mesh), false); EditorGUI.EndDisabledGroup(); } if (chunkTarget.mesh != null) { if (!EditorCommon.IsMainAsset(chunkTarget.mesh)) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Mesh EditorApplication.delayCall += () => { string path = EditorUtility.SaveFilePanel("Save mesh", chunkCore.GetDefaultPath(), string.Format("{0}_{1}_mesh.asset", objectTarget.gameObject.name, chunkTarget.chunkName), "asset"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(objectTarget, "Save Mesh"); Undo.RecordObject(chunkTarget, "Save Mesh"); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(Mesh.Instantiate(chunkTarget.mesh), path); chunkTarget.mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path); Refresh(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Mesh Undo.RecordObject(objectTarget, "Reset Mesh"); Undo.RecordObject(chunkTarget, "Reset Mesh"); chunkTarget.mesh = null; Refresh(); #endregion } } } EditorGUILayout.EndHorizontal(); } #endregion #region Vertex Count { EditorGUILayout.LabelField("Vertex Count", chunkTarget.mesh != null ? chunkTarget.mesh.vertexCount.ToString() : ""); } #endregion EditorGUI.indentLevel--; } #endregion #region Material if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Individual) { EditorGUILayout.LabelField("Material", EditorStyles.boldLabel); EditorGUI.indentLevel++; #region Material for (int i = 0; i < chunkTarget.materials.Count; i++) { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(chunkTarget.materials[i], typeof(Material), false); EditorGUI.EndDisabledGroup(); } if (chunkTarget.materials[i] != null) { if (!EditorCommon.IsMainAsset(chunkTarget.materials[i])) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Material var index = i; EditorApplication.delayCall += () => { string defaultName = string.Format("{0}_{1}_mat{2}.mat", objectTarget.gameObject.name, chunkTarget.chunkName, index); string path = EditorUtility.SaveFilePanel("Save material", chunkCore.GetDefaultPath(), defaultName, "mat"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(objectTarget, "Save Material"); Undo.RecordObject(chunkTarget, "Save Material"); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.CreateAsset(Material.Instantiate(chunkTarget.materials[index]), path); chunkTarget.materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path); Refresh(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Material Undo.RecordObject(objectTarget, "Reset Material"); Undo.RecordObject(chunkTarget, "Reset Material"); chunkTarget.materials[i] = EditorCommon.ResetMaterial(chunkTarget.materials[i]); Refresh(); #endregion } } } EditorGUILayout.EndHorizontal(); } #endregion EditorGUI.indentLevel--; } #endregion #region Texture if (objectTarget.materialMode == VoxelChunksObject.MaterialMode.Individual) { EditorGUILayout.LabelField("Texture", EditorStyles.boldLabel); EditorGUI.indentLevel++; #region Texture { EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(chunkTarget.atlasTexture, typeof(Texture2D), false); EditorGUI.EndDisabledGroup(); } if (chunkTarget.atlasTexture != null) { if (!EditorCommon.IsMainAsset(chunkTarget.atlasTexture)) { if (GUILayout.Button("Save", GUILayout.Width(48), GUILayout.Height(16))) { #region Create Texture EditorApplication.delayCall += () => { string defaultName = string.Format("{0}_{1}_tex.png", objectTarget.gameObject.name, chunkTarget.chunkName); string path = EditorUtility.SaveFilePanel("Save atlas texture", chunkCore.GetDefaultPath(), defaultName, "png"); if (!string.IsNullOrEmpty(path)) { if (path.IndexOf(Application.dataPath) < 0) { EditorCommon.SaveInsideAssetsFolderDisplayDialog(); } else { Undo.RecordObject(objectTarget, "Save Atlas Texture"); Undo.RecordObject(chunkTarget, "Save Atlas Texture"); File.WriteAllBytes(path, chunkTarget.atlasTexture.EncodeToPNG()); path = FileUtil.GetProjectRelativePath(path); AssetDatabase.ImportAsset(path); objectCore.SetTextureImporterSetting(path, chunkTarget.atlasTexture); chunkTarget.atlasTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(path); Refresh(); } } }; #endregion } } { if (GUILayout.Button("Reset", GUILayout.Width(48), GUILayout.Height(16))) { #region Reset Texture Undo.RecordObject(objectTarget, "Reset Atlas Texture"); Undo.RecordObject(chunkTarget, "Reset Atlas Texture"); chunkTarget.atlasTexture = null; Refresh(); #endregion } } } EditorGUILayout.EndHorizontal(); } #endregion #region Texture Size { EditorGUILayout.LabelField("Texture Size", chunkTarget.atlasTexture != null ? string.Format("{0} x {1}", chunkTarget.atlasTexture.width, chunkTarget.atlasTexture.height) : ""); } #endregion EditorGUI.indentLevel--; } #endregion EditorGUILayout.EndVertical(); } } else { EditorGUILayout.Space(); } #endregion #region Refresh if (GUILayout.Button("Refresh")) { Undo.RecordObject(objectTarget, "Inspector"); Undo.RecordObject(chunkTarget, "Inspector"); Refresh(); } #endregion }