public static void DrawBlockEditor(OCBlock block, OCBlockSet blockSet) { GUILayout.BeginVertical(GUI.skin.box); { string name = EditorGUILayout.TextField("Name", block.GetName()); block.SetName( FixNameString(name) ); if(block is OCGlassBlock) { OCGlassBlock glass = (OCGlassBlock)block; GameObject interior = (GameObject)EditorGUILayout.ObjectField("Interior", glass.GetInterior(), typeof(GameObject), true, null); glass.SetInterior( interior ); } int atlas = EditorGUIUtils.Popup( "Atlas", block.AtlasID, blockSet.Atlases ); block.AtlasID = atlas; int light = EditorGUILayout.IntField("Light", block.GetLight()); block.SetLight(light); } GUILayout.EndVertical(); 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 static bool DrawItem(Rect position, OCBlock block, bool selected, int index) { Rect texturePosition = position; texturePosition.height = texturePosition.width; Rect labelPosition = position; labelPosition.yMin += texturePosition.height; if(selected) BlockEditorUtils.FillRect(labelPosition, new Color( 61/255f, 128/255f, 223/255f )); if(block != null) { block.DrawPreview(texturePosition); GUI.Label(labelPosition, block.GetName()); } else { BlockEditorUtils.FillRect(texturePosition, Color.grey); GUI.Label(labelPosition, "Null"); } if(Event.current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) { Event.current.Use(); return true; } return false; }