private static void ResetAllSavedAssets(MenuCommand menuCommand)
        {
            var explosionObject = menuCommand.context as VoxelObjectExplosion;

            if (explosionObject == null)
            {
                return;
            }

            var explosionCore = new VoxelObjectExplosionCore(explosionObject);

            Undo.RecordObject(explosionObject, "Reset All Assets");

            explosionCore.ResetAllAssets();
            explosionCore.Generate();
            InternalEditorUtility.RepaintAllViews();
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            explosionBase = explosionObject = target as VoxelObjectExplosion;
            if (explosionObject == null)
            {
                return;
            }
            explosionCore = explosionObjectCore = new VoxelObjectExplosionCore(explosionObject);
            if (explosionCore.voxelBase == null)
            {
                Undo.DestroyObjectImmediate(explosionBase);
                return;
            }
            OnEnableInitializeSet();
        }
        public static void StaticForceGenerate(VoxelBaseExplosion voxelBase)
        {
            VoxelBaseExplosionCore voxelCore = null;

            if (voxelBase is VoxelObjectExplosion)
            {
                voxelCore = new VoxelObjectExplosionCore(voxelBase);
            }
            else if (voxelBase is VoxelChunksObjectExplosion)
            {
                voxelCore = new VoxelChunksObjectExplosionCore(voxelBase);
            }
            else if (voxelBase is VoxelFrameAnimationObjectExplosion)
            {
                voxelCore = new VoxelFrameAnimationObjectExplosionCore(voxelBase);
            }
            else if (voxelBase is VoxelSkinnedAnimationObjectExplosion)
            {
                voxelCore = new VoxelSkinnedAnimationObjectExplosionCore(voxelBase);
            }
            else
            {
                Assert.IsTrue(false);
            }
            if (voxelCore == null)
            {
                return;
            }

            voxelCore.ResetAllAssets();
            voxelCore.Generate();

            #region Extra
            if (voxelCore is VoxelSkinnedAnimationObjectExplosionCore)
            {
                var voxelCoreEx = voxelCore as VoxelSkinnedAnimationObjectExplosionCore;
                if (voxelCoreEx.explosionObject.meshes != null &&
                    voxelCoreEx.explosionObject.meshes.Count > 0 &&
                    voxelCoreEx.explosionObject.meshes[0].bakeMesh != null)
                {
                    voxelCoreEx.Bake();
                }
            }
            #endregion
        }
        private static void ResetAllSavedAssets(MenuCommand menuCommand)
        {
            var explosionObject = menuCommand.context as VoxelObjectExplosion;

            if (explosionObject == null)
            {
                return;
            }

            var explosionCore = new VoxelObjectExplosionCore(explosionObject);

            Undo.RecordObject(explosionObject, "Reset All Assets");

            #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;
                    }
                    if (!IsMainAsset(explosionObject.materials[i]))
                    {
                        explosionObject.materials[i] = null;
                    }
                    else
                    {
                        explosionObject.materials[i] = Instantiate <Material>(explosionObject.materials[i]);
                    }
                }
            }
            #endregion

            explosionCore.Generate();
            InternalEditorUtility.RepaintAllViews();
        }
        private static void SaveAllUnsavedAssets(MenuCommand menuCommand)
        {
            var explosionObject = menuCommand.context as VoxelObjectExplosion;

            if (explosionObject == null)
            {
                return;
            }

            var explosionCore = new VoxelObjectExplosionCore(explosionObject);

            var folder = EditorUtility.OpenFolderPanel("Save all", explosionCore.voxelBaseCore.GetDefaultPath(), null);

            if (string.IsNullOrEmpty(folder))
            {
                return;
            }
            if (folder.IndexOf(Application.dataPath) < 0)
            {
                EditorCommon.SaveInsideAssetsFolderDisplayDialog();
                return;
            }

            Undo.RecordObject(explosionObject, "Save All Unsaved Assets");

            #region Mesh
            if (explosionObject.meshes != null)
            {
                for (int i = 0; i < explosionObject.meshes.Count; i++)
                {
                    if (explosionObject.meshes[i] != null && explosionObject.meshes[i].mesh != null && !EditorCommon.IsMainAsset(explosionObject.meshes[i].mesh))
                    {
                        var path = folder + "/" + string.Format("{0}_explosion_mesh{1}.asset", explosionObject.gameObject.name, i);
                        path = FileUtil.GetProjectRelativePath(path);
                        path = AssetDatabase.GenerateUniqueAssetPath(path);
                        AssetDatabase.CreateAsset(Mesh.Instantiate(explosionObject.meshes[i].mesh), path);
                        explosionObject.meshes[i].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path);
                    }
                }
            }
            #endregion

            #region Material
            if (explosionObject.materials != null)
            {
                for (int index = 0; index < explosionObject.materials.Count; index++)
                {
                    if (explosionObject.materials[index] == null)
                    {
                        continue;
                    }
                    if (EditorCommon.IsMainAsset(explosionObject.materials[index]))
                    {
                        continue;
                    }
                    var path = folder + "/" + string.Format("{0}_explosion_mat{1}.mat", explosionObject.gameObject.name, index);
                    path = FileUtil.GetProjectRelativePath(path);
                    path = AssetDatabase.GenerateUniqueAssetPath(path);
                    AssetDatabase.CreateAsset(Material.Instantiate(explosionObject.materials[index]), path);
                    explosionObject.materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path);
                }
            }
            #endregion

            explosionCore.Generate();
            InternalEditorUtility.RepaintAllViews();
        }