void ShowZhongGuai(string[] FarmingType) { /*出生到地图上(锁定Y轴)*/ BornAtMap = EditorGUILayout.Toggle(EditorStringConfig.getString(10017), BornAtMap); if (BornAtMap) { Vector2 bornPos = new Vector2(SceneEditorSettings.BronPostionX, SceneEditorSettings.BronPostionZ); /*出生坐标*/ bornPos = EditorGUILayout.Vector2Field(EditorStringConfig.getString(10018), bornPos); SceneEditorSettings.BronPostionX = (int)bornPos.x; SceneEditorSettings.BronPostionZ = (int)bornPos.y; } else { Vector3 bornPos = new Vector3(SceneEditorSettings.BronPostionX, SceneEditorSettings.BronPostionY, SceneEditorSettings.BronPostionZ); /*出生坐标*/ bornPos = EditorGUILayout.Vector3Field(EditorStringConfig.getString(10018), bornPos); SceneEditorSettings.BronPostionX = (int)bornPos.x; SceneEditorSettings.BronPostionY = (int)bornPos.y; SceneEditorSettings.BronPostionZ = (int)bornPos.z; } GUILayout.Space(20f); GUILayout.BeginHorizontal(); /*创建*/ if (GUILayout.Button(EditorStringConfig.getString(10015) + FarmingType[SceneEditorSettings.farmingTypeIndex], GUILayout.Width(150), GUILayout.Height(40))) { SceneEditorTools.CreatePlant(PlantSourceObject[PlantSourceIndex], new Vector3(SceneEditorSettings.BronPostionX, SceneEditorSettings.BronPostionY, SceneEditorSettings.BronPostionZ), Vector3.one, (SceneElementType)SceneEditorSettings.farmingTypeIndex, BornAtMap); } /*保存配置表*/ if (GUILayout.Button(EditorStringConfig.getString(10019), GUILayout.Width(150), GUILayout.Height(40))) { SceneEditorTools.AutoGenerateSettingFile(); } /*导出游戏数据*/ if (GUILayout.Button(EditorStringConfig.getString(10020), GUILayout.Width(150), GUILayout.Height(40))) { SceneEditorTools.AutoGenerateGameData(); } GUILayout.EndHorizontal(); }
void OnGUI() { // NewDrawTest(); // return; SetFontStyle(Color.gray, 18, FontStyle.Italic, EditorStyles.label); GUILayout.BeginHorizontal(); /*版本:1.0.1*/ GUILayout.Label(EditorStringConfig.getString(10000), style); GUILayout.EndHorizontal(); DrawLine(); GUILayout.Space(15); GUILayout.BeginHorizontal(); SetFontStyle(Color.gray, 15, FontStyle.Italic); /*正在编辑地图:*/ GUILayout.Label(EditorStringConfig.getString(10001), style); SceneEditorSettings.currMap = EditorGUILayout.ObjectField(SceneEditorSettings.currMap, typeof(GameObject), true) as GameObject; /*刷新数据*/ if (GUILayout.Button(EditorStringConfig.getString(10002, 10003), GUILayout.Width(60), GUILayout.Height(16))) { RefreshAllData(); } GUILayout.EndHorizontal(); GameObject currMap = SceneEditorSettings.currMap; bool isHaveMap = currMap == null; if (isHaveMap) { /*未检测到场景,你可以\n1.创建一个新场景. \n2.导入一个已经保存的场景配置表.\n3.从Hierarchy视图中拖入一个已有的场景*/ EditorGUILayout.HelpBox(EditorStringConfig.getString(10021), MessageType.Error); ShowMapMenu(); } else { GUILayout.Space(10); GUILayout.BeginHorizontal(); /*销毁地图*/ if (GUILayout.Button(EditorStringConfig.getString(10022), GUILayout.Width(150), GUILayout.Height(40))) { /*"友情提示","你确定要销毁地图","确定","取消"*/ bool result = EditorUtility.DisplayDialog(EditorStringConfig.getString(10023), EditorStringConfig.getString(10024) + currMap.name, EditorStringConfig.getString(10025), EditorStringConfig.getString(10026)); if (result) { GameObject currMapObj = GameObject.Find(currMap.name); DestroyImmediate(currMapObj); currMapId = 0; SceneEditorSettings.currMap = null; } } /*载入配置表*/ if (GUILayout.Button(EditorStringConfig.getString(10016), GUILayout.Width(150), GUILayout.Height(40))) { /*"友情提示","是否先保存当前场景?","确定","取消"*/ bool result = EditorUtility.DisplayDialog(EditorStringConfig.getString(10023), EditorStringConfig.getString(10027), EditorStringConfig.getString(10025), EditorStringConfig.getString(10026)); if (result) { SceneEditorTools.AutoGenerateSettingFile(); } else { GameObject currMapObj = GameObject.Find(currMap.name); DestroyImmediate(currMapObj); SceneEditorSettings.currMap = null; } SceneEditorTools.AutoImportSettingFile(); } GUILayout.EndHorizontal(); //如果当前创建了地图 if (currMap != null) { GUILayout.Space(10); DrawLine(); SetFontStyle(Color.gray, 12, FontStyle.Italic, EditorStyles.foldout); /*地图编辑*/ SceneEditorSettings.isEditorMapGrid = EditorGUILayout.Foldout(SceneEditorSettings.isEditorMapGrid, EditorStringConfig.getString(10004), style); if (SceneEditorSettings.isEditorMapGrid) { ++EditorGUI.indentLevel; GameObject map = SceneEditorSettings.currMap; UISceneMap uimap = map.GetComponent <UISceneMap>(); if (uimap != null) { bool oldShowMap = uimap.isShowMap; /*显示网格*/ uimap.isShowMap = EditorGUILayout.Toggle(EditorStringConfig.getString(10005), uimap.isShowMap); if (oldShowMap != uimap.isShowMap) { SceneView.RepaintAll(); } float gridwidth = uimap.renderTo.x - uimap.renderFrom.x; float gridheight = uimap.renderTo.y - uimap.renderFrom.y; Vector2 gridSize = new Vector3(gridwidth, gridheight); Vector2 oldgridSize = gridSize; /*网格大小*/ gridSize = EditorGUILayout.Vector2Field(EditorStringConfig.getString(10006), gridSize); uimap.renderFrom = new Vector3(-gridSize.x / 2f, -gridSize.y / 2f, 0); uimap.renderTo = new Vector3(gridSize.x / 2f, gridSize.y / 2f, 0); if (oldgridSize != gridSize) { SceneView.RepaintAll(); } Color oldaxisColors = uimap.axisColors; /*网络颜色*/ uimap.axisColors = EditorGUILayout.ColorField(EditorStringConfig.getString(10007), uimap.axisColors); if (oldaxisColors != uimap.axisColors) { SceneView.RepaintAll(); } } --EditorGUI.indentLevel; } //显示网络编辑模块 GUILayout.Space(10); DrawLine(); string[] FarmingType = System.Enum.GetNames(typeof(SceneElementType)); /*请选择*/ FarmingType[0] = EditorStringConfig.getString(10008); SetFontStyle(Color.gray, 12, FontStyle.Italic, EditorStyles.foldout); /*地图种怪编辑*/ SceneEditorSettings.isOpenFarming = EditorGUILayout.Foldout(SceneEditorSettings.isOpenFarming, EditorStringConfig.getString(10009), style); if (SceneEditorSettings.isOpenFarming) { ++EditorGUI.indentLevel; EditorGUILayout.BeginHorizontal(); /*种植类型*/ SceneEditorSettings.farmingTypeIndex = EditorGUILayout.Popup(EditorStringConfig.getString(10010), SceneEditorSettings.farmingTypeIndex, FarmingType); /*编辑*/ if (GUILayout.Button(EditorStringConfig.getString(10011), GUILayout.Width(50), GUILayout.Height(16))) { SceneEditorGridWindow window = (SceneEditorGridWindow)EditorWindow.GetWindow(typeof(SceneEditorGridWindow)); window.Init(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); //如果用户选择了一种类型 if (SceneEditorSettings.farmingTypeIndex > 0) { Object PlantSource = SceneEditorSettings.GetPlantFileObject((SceneElementType)SceneEditorSettings.farmingTypeIndex); EditorGUILayout.BeginHorizontal(); /*资源来源*/ Object currPlantSource = EditorGUILayout.ObjectField(EditorStringConfig.getString(10012), PlantSource, typeof(Object)); //资源文件夹是否发生了改变 bool isChanged = PlantSource != currPlantSource; SceneEditorSettings.SetPlantFileObject((SceneElementType)SceneEditorSettings.farmingTypeIndex, currPlantSource); /*刷新*/ if (GUILayout.Button(EditorStringConfig.getString(10002), GUILayout.Width(50), GUILayout.Height(16))) { if (currPlantSource != null) { GetGameObjectsNameInFolder(currPlantSource); } } EditorGUILayout.EndHorizontal(); if (PlantSource != null) { if (isChanged) { GetGameObjectsNameInFolder(currPlantSource); } GUILayout.Space(5); PlantSourceIndex = EditorGUILayout.Popup(FarmingType[SceneEditorSettings.farmingTypeIndex] + "名称:", PlantSourceIndex, PlantSourceName.ToArray()); } GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Space(this.position.width - 100); /*更新地图分类*/ if (GUILayout.Button(EditorStringConfig.getString(10013), GUILayout.Width(100), GUILayout.Height(40))) { SceneEditorSettings.currMap.GetComponent <UISceneMap>().RefreshClassification(); } GUILayout.EndHorizontal(); GUILayout.Space(5); ShowZhongGuai(FarmingType); } --EditorGUI.indentLevel; } } } GUILayout.Space(5); DrawLine(); }