public static void DrawBlockEditor(OCBlock block, OCBlockSet blockSet) { UnityEngine.GUILayout.BeginVertical(UnityEngine.GUI.skin.box); { string name = EditorGUILayout.TextField("Name", block.GetName()); block.SetName(FixNameString(name)); if (block is OCGlassBlock) { OCGlassBlock glass = (OCGlassBlock)block; UnityEngine.GameObject interior = (UnityEngine.GameObject)EditorGUILayout.ObjectField("Interior", glass.GetInterior(), typeof(UnityEngine.GameObject), true, null); glass.SetInterior(interior); } int atlas = BlockEditorUtils.Popup("Atlas", block.AtlasID, blockSet.Atlases); block.AtlasID = atlas; int light = EditorGUILayout.IntField("Light", block.GetLight()); block.SetLight(light); } UnityEngine.GUILayout.EndVertical(); UnityEngine.Texture texture = block.GetTexture(); if (texture != null) { FieldInfo field = DrawFacesList(block, texture); int face = (int)field.GetValue(block); DrawFaceEditor(ref face, block.Atlas, ref atlasMatrix); field.SetValue(block, face); } }
private void DrawBlockSet(OCBlockSet blockSet) { GUILayout.BeginVertical(GUI.skin.box); int oldSelectedBlock = selectedBlock; // Next line pushes the blockSet to BlockSetViewer selectedBlock = OpenCog.BlockSetViewer.SelectionGrid(blockSet, selectedBlock, GUILayout.MinHeight(200), GUILayout.MaxHeight(300)); if (selectedBlock != oldSelectedBlock) { GUIUtility.keyboardControl = 0; } EditorGUILayout.Separator(); GUILayout.BeginHorizontal(); foreach (Type type in blockTypes) { string name = type.Name; if (name.EndsWith("Block")) { name = name.Substring(0, name.Length - 5); } if (GUILayout.Button(name)) { OCBlock newBlock = (OCBlock)CreateInstance(type); newBlock.SetName("New " + type.ToString()); newBlock.Init(blockSet); OCBlock[] blocks = blockSet.Blocks; ArrayUtility.Add <OCBlock>(ref blocks, newBlock); blockSet.Blocks = blocks; selectedBlock = blocks.Length - 1; EditorGUIUtility.keyboardControl = 0; GUI.changed = true; } } GUILayout.EndHorizontal(); if (GUILayout.Button("Remove")) { OCBlock[] blocks = blockSet.Blocks; ArrayUtility.RemoveAt <OCBlock>(ref blocks, selectedBlock); blockSet.Blocks = blocks; selectedBlock = Mathf.Clamp(selectedBlock, 0, blocks.Length - 1); GUI.changed = true; } GUILayout.EndVertical(); }