/// <summary> /// 绘制Blocks页面 /// </summary> /// <param name="data"></param> public void DrawBlocksPanel(BlockTerrainData data) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); MyGUITools.SetBackgroundColor(Color.green); if (GUILayout.Button("Add New Block Definition")) { BlockDefinition newdef = new BlockDefinition(); newdef.id = data.blockDefinitions.Count; data.blockDefinitions.Add(newdef); } MyGUITools.RestoreBackgroundColor(); GUILayout.EndHorizontal(); // EditorGUI.indentLevel++; GUILayout.Label("Block Count(" + data.blockDefinitions.Count + ")"); var contents = new List <GUIContent>(); for (int i = 0; i < data.blockDefinitions.Count; i++) { var def = data.blockDefinitions[i]; if (i == selectBlockDefIndex) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical((GUIStyle)"MeTransitionSelect", GUILayout.Height(200)); GUILayout.Toggle(true, string.Format("ID:{0},Name:{1}", def.id, def.name), (GUIStyle)"MeTransitionSelectHead", GUILayout.Height(30)); def = data.blockDefinitions[i]; if (def is SpriteBlockDefinition) { var sprDef = def as SpriteBlockDefinition; sprDef.id = EditorGUILayout.IntField("ID", sprDef.id); sprDef.name = EditorGUILayout.TextField("Name", sprDef.name); //贴图设置 EditorGUILayout.PrefixLabel("CreateMode"); blockCreateModeIndex = GUILayout.Toolbar(blockCreateModeIndex, blockCreateModes); if (blockCreateModeIndex == 0) { var temp = EditorGUILayout.ObjectField("All Face", sprDef.top, typeof(Sprite), false) as Sprite; if (temp != null && temp != sprDef.top) { sprDef.top = temp; sprDef.bottom = sprDef.front = sprDef.back = sprDef.left = sprDef.right = sprDef.top; } } else if (blockCreateModeIndex == 1) { sprDef.top = EditorGUILayout.ObjectField("Top Face", sprDef.top, typeof(Sprite), false) as Sprite; var temp = EditorGUILayout.ObjectField("Other Face", sprDef.bottom, typeof(Sprite), false) as Sprite; if (temp != null && temp != sprDef.bottom) { sprDef.bottom = temp; sprDef.front = sprDef.back = sprDef.left = sprDef.right = sprDef.bottom; } } else if (blockCreateModeIndex == 2) { sprDef.top = EditorGUILayout.ObjectField("Top Face", sprDef.top, typeof(Sprite), false) as Sprite; sprDef.bottom = EditorGUILayout.ObjectField("Bottom Face", sprDef.bottom, typeof(Sprite), false) as Sprite; var temp = EditorGUILayout.ObjectField("Other Face", sprDef.front, typeof(Sprite), false) as Sprite; if (temp != null && temp != sprDef.front) { sprDef.front = temp; sprDef.back = sprDef.left = sprDef.right = sprDef.front; } } else if (blockCreateModeIndex == 3) { sprDef.top = EditorGUILayout.ObjectField("Top Face", sprDef.top, typeof(Sprite), false) as Sprite; sprDef.bottom = EditorGUILayout.ObjectField("Bottom Face", sprDef.bottom, typeof(Sprite), false) as Sprite; sprDef.front = EditorGUILayout.ObjectField("Front Face", sprDef.front, typeof(Sprite), false) as Sprite; sprDef.back = EditorGUILayout.ObjectField("Back Face", sprDef.back, typeof(Sprite), false) as Sprite; sprDef.left = EditorGUILayout.ObjectField("Left Face", sprDef.left, typeof(Sprite), false) as Sprite; sprDef.right = EditorGUILayout.ObjectField("Right Face", sprDef.right, typeof(Sprite), false) as Sprite; } } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); MyGUITools.SetBackgroundColor(Color.red); if (GUILayout.Button("Del", GUILayout.MinWidth(80))) { data.blockDefinitions.RemoveAt(selectBlockDefIndex); } MyGUITools.RestoreBackgroundColor(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } else { var flag = GUILayout.Toggle(false, string.Format("ID:{0},Name:{1}", def.id, def.name), (GUIStyle)"OL Title"); if (flag == true) { selectBlockDefIndex = i; } } } }
/// <summary> /// 绘制Layers页面 /// </summary> /// <param name="data"></param> public void DrawLayersPanel(BlockTerrainData data) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); MyGUITools.SetBackgroundColor(Color.green); if (GUILayout.Button("Add New Layer")) { BlockTerrainLayer layer = new BlockTerrainLayer(0, 255); data.layers.Add(layer); } MyGUITools.RestoreBackgroundColor(); EditorGUILayout.EndHorizontal(); for (int i = 0; i < data.layers.Count; i++) { var layer = data.layers[i]; if (i == selectLayerDefIndex) { EditorGUILayout.Space(); EditorGUILayout.BeginVertical((GUIStyle)"MeTransitionSelect", GUILayout.Height(100)); GUILayout.Toggle(false, string.Format("{0}:Start:{1}-End:{2}", i, layer.start, layer.end), (GUIStyle)"MeTransitionSelectHead", GUILayout.Height(30)); GUILayout.BeginHorizontal(); GUILayout.Label("Start"); layer.start = EditorGUILayout.IntField(layer.start); GUILayout.Label("End "); layer.end = EditorGUILayout.IntField(layer.end); GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); MyGUITools.SetBackgroundColor(Color.green); if (GUILayout.Button("Add New Item")) { BlockTerrainLayerItem newItem = new BlockTerrainLayerItem(); layer.items.Add(newItem); } MyGUITools.RestoreBackgroundColor(); EditorGUILayout.EndHorizontal(); for (int j = 0; j < layer.items.Count; j++) { var item = layer.items[j]; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Block"); item.blockId = EditorGUILayout.IntPopup(item.blockId, GetBlockNames(data), GetBlockIDs(data)); GUILayout.Label("Weight "); item.weight = EditorGUILayout.FloatField(item.weight); MyGUITools.SetBackgroundColor(Color.red); if (GUILayout.Button("Del")) { layer.items.RemoveAt(j); } MyGUITools.RestoreBackgroundColor(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } else { var flag = GUILayout.Toggle(false, string.Format("{0}:Start:{1}-End:{2}", i, layer.start, layer.end), (GUIStyle)"OL Title"); if (flag == true) { selectLayerDefIndex = i; } } } }