private void OnGUI() { go = (GameObject)EditorGUILayout.ObjectField("画笔模型", go, typeof(GameObject), false); brushName = EditorGUILayout.TextField("画笔名称", brushName); if (data != null) { data.buildingType = (MapCellData.BuildingType)EditorGUILayout.EnumPopup("笔刷索引", data.buildingType); MapCellTool.DrawBrush(data); } if (GUILayout.Button("Create")) { if (!go) { go = new GameObject("DefaultBrush"); CreateDefault(go, brushName); } else { go = Instantiate(go); } var brush = go.AddComponent <HexBrush>(); brush.data = data; PrefabUtility.SaveAsPrefabAssetAndConnect(go, string.Format("{0}/{1}.prefab", path, brushName), InteractionMode.UserAction); GameObject.DestroyImmediate(go); go = null; data = new MapCellData(); } }
Hex InitHex(MapCellData data) { var position = new Vector2(data.x, data.y); var pos = World.ToPixel(position); var hex = new GameObject(); var hm = hex.AddComponent <Hex>(); hm.data = data; hm.HexPosition = position; hex.transform.position = pos; hm.InitializeModel(); garbage.Add(hex); hm.HexModel.meshRenderer.sharedMaterial = new Material(Shader.Find("Diffuse")); MapCellTool.OnPropertyChange(hm); return(hm); }
void OnGUIBrushInfo(Rect size) { GUILayout.BeginArea(size); BrushInfo = EditorGUILayout.BeginFoldoutHeaderGroup(BrushInfo, "BrushInfo"); if (BrushInfo) { if (currentSelect) { HexBrush hb = currentSelect.GetComponent <HexBrush>(); if (hb) { MapCellTool.DrawBrush(hb.data); } } } EditorGUILayout.EndFoldoutHeaderGroup(); GUILayout.EndArea(); }
void OnGUIInfo(Rect size) { GUILayout.BeginArea(size); Info = EditorGUILayout.BeginFoldoutHeaderGroup(Info, "Info"); if (Info) { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); if (Selection.gameObjects != null) { foreach (var k in Selection.gameObjects) { Hex cell = k.gameObject.GetComponent <Hex>(); if (cell) { MapCellTool.Draw(cell); } HexBuilding build = k.gameObject.GetComponent <HexBuilding>(); if (build) { if (build.hex) { GUI.color = Color.red; EditorGUILayout.LabelField("选中了建筑"); GUI.color = Color.white; MapCellTool.Draw(build.hex); } } } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndFoldoutHeaderGroup(); GUILayout.EndArea(); }