Example #1
0
    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();
        }
    }
Example #2
0
 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();
 }