private void OnEnable() { voxelObject = (Volume) target; Undo.undoRedoPerformed += () => voxelObject.OnUndoRedo(); voxelSizeProperty = serializedObject.FindProperty("VoxelSize"); overlapAmountProperty = serializedObject.FindProperty("OverlapAmount"); collisionMode = serializedObject.FindProperty("CollisionMode"); meshingMode = serializedObject.FindProperty("MeshingMode"); meshCompression = serializedObject.FindProperty("MeshCompression"); colliderMeshingMode = serializedObject.FindProperty("MeshColliderMeshingMode"); separateColliderMesh = serializedObject.FindProperty("GenerateMeshColliderSeparately"); pivotProperty = serializedObject.FindProperty("Pivot"); voxelSize = voxelSizeProperty.floatValue; overlapAmount = overlapAmountProperty.floatValue; pivot = pivotProperty.vector3Value; selfShadeInt = serializedObject.FindProperty("SelfShadingIntensity"); drawGrid = voxelObject.DrawGrid; drawMesh = voxelObject.DrawMesh; runtimeOnlyMesh = serializedObject.FindProperty("RuntimOnlyMesh"); material = serializedObject.FindProperty("Material"); if (voxelObject != null && !Application.isPlaying && PrefabUtility.GetPrefabType(voxelObject) != PrefabType.Prefab && PrefabUtility.GetPrefabType(voxelObject) != PrefabType.PrefabInstance) { string path = Path.Combine(Helper.GetMeshStorePath(), voxelObject.AssetGuid); if (!Directory.Exists(path)) voxelObject.CreateChunks(); } if (!Application.isPlaying && voxelObject.gameObject.activeSelf && PrefabUtility.GetPrefabType(voxelObject) != PrefabType.Prefab && !voxelObject.RuntimOnlyMesh) foreach (var frame in voxelObject.Frames) { if (frame.HasDeserialized) frame.UpdateChunks(true); frame.HasDeserialized = false; } paintMode = voxelObject.PaintMode; if (EditorPersistence.SelectBox.BottomLeftFront.X > voxelObject.XSize - 1 || EditorPersistence.SelectBox.BottomLeftFront.Y > voxelObject.YSize - 1 || EditorPersistence.SelectBox.BottomLeftFront.Z > voxelObject.ZSize - 1 || EditorPersistence.SelectBox.TopRightBack.X > voxelObject.XSize - 1 || EditorPersistence.SelectBox.TopRightBack.Y > voxelObject.YSize - 1 || EditorPersistence.SelectBox.TopRightBack.Z > voxelObject.ZSize - 1) EditorPersistence.SelectBox = new PicaVoxelBox(0, 0, 0, voxelObject.XSize - 1, voxelObject.YSize - 1, voxelObject.ZSize - 1); }