Esempio n. 1
0
        public static void CreateSetting()
        {
            if (!Directory.Exists(MapEditorDef.MapSetingPath))
            {
                Directory.CreateDirectory(MapEditorDef.MapSetingPath);
            }
            MapSetting setting = CreateInstance <MapSetting>();

            setting.name = "地图设置";
            AssetDatabase.CreateAsset(setting, MapEditorDef.MapSetingPath + "/地图设置.asset");
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            Selection.activeObject = setting;
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            if (GUILayout.Button("´´½¨Ä¿Â¼", GUILayout.Height(30)))
            {
                MapSetting mapSetting = target as MapSetting;
                Directory.CreateDirectory(mapSetting.MapSearchPath);
                Directory.CreateDirectory(mapSetting.MapExportSavePath);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
        }
Esempio n. 3
0
        private void OnGUI()
        {
            if (!ContextDataCache.TryGetContextData <GUIStyle>("BigLabel", out var bigLabel))
            {
                bigLabel.value              = new GUIStyle(GUI.skin.label);
                bigLabel.value.fontSize     = 18;
                bigLabel.value.fontStyle    = FontStyle.Bold;
                bigLabel.value.alignment    = TextAnchor.MiddleLeft;
                bigLabel.value.stretchWidth = true;
            }

            //工具栏
            GUILayoutExtension.HorizontalGroup(() =>
            {
                string selMap = currSelMap == null ? "Null" : currSelMap.mapId.ToString();
                GUILayout.Label($"当前地图:{selMap}", bigLabel.value);

                if (GUILayout.Button("加载地图", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                {
                    List <string> mapNames = new List <string>();
                    for (int i = 0; i < maps.Count; i++)
                    {
                        mapNames.Add(maps[i].mapId.ToString());
                    }
                    MiscHelper.Menu(mapNames, (string selMap) =>
                    {
                        ED_MapCom mapAsset = GetMap(int.Parse(selMap));
                        GameObject mapGo   = (GameObject)PrefabUtility.InstantiatePrefab(mapAsset.gameObject);
                        OnChangeMap(mapGo.GetComponent <ED_MapCom>());
                    });
                }

                if (currSelMap != null)
                {
                    if (GUILayout.Button("保存地图", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                    {
                        SaveMap(currSelMap);
                        Refresh();
                    }
                }

                if (GUILayout.Button("新建地图", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                {
                    MiscHelper.Input("输入地图Id", (string x) =>
                    {
                        if (GetMap(int.Parse(x)) != null)
                        {
                            Debug.LogError($"地图Id重复>>>>{x}");
                            return;
                        }
                        SaveMap(currSelMap);
                        ED_MapCom mapCom = MapEditorDef.CreateMapGo(x);
                        mapCom.SetUid(GetMapStartUid());
                        OnChangeMap(mapCom);
                    });
                }

                if (GUILayout.Button("导出所有配置", GUILayout.Width(BtnWidth), GUILayout.Height(BtnHeight)))
                {
                    ED_MapCom.ActorCnfs   = MapEditorWindow.ActorCnfs;
                    List <ED_MapCom> maps = MapSetting.GetAllMaps();
                    for (int i = 0; i < maps.Count; i++)
                    {
                        GameObject mapGo    = GameObject.Instantiate(maps[i].gameObject);
                        ED_MapCom eD_MapCom = mapGo.GetComponent <ED_MapCom>();
                        MapModel model      = eD_MapCom.ExportData();

                        string filePath = MapSetting.GetMapModelSavePath(model.mapId.ToString());
                        IOHelper.WriteText(JsonMapper.ToJson(model), filePath);

                        DestroyImmediate(eD_MapCom.gameObject);
                        Debug.Log($"地图配置生成成功>>>>{filePath}");
                    }
                    AssetDatabase.SaveAssets();
                    AssetDatabase.Refresh();
                }
            }, GUILayout.Height(50));

            GUILayoutExtension.HorizontalGroup(() =>
            {
                //演员分组列表
                GUILayoutExtension.VerticalGroup(() =>
                {
                    GUILayout.Label("演员列表", bigLabel.value);
                    for (int i = 0; i < ActorCnfs.Count; i++)
                    {
                        if (GUILayout.Button($"{ActorCnfs[i].name}-{ActorCnfs[i].id}", GUILayout.Width(100), GUILayout.Height(BtnHeight)))
                        {
                            ED_ActorCom actorCom   = currSelMap.CreateActor(ActorCnfs[i]);
                            Selection.activeObject = actorCom;
                        }
                    }
                }, GUILayout.Width(50));
            });
        }
Esempio n. 4
0
 private void Refresh()
 {
     ActorCnfs = MapSetting.GetActorCnfs();
     maps      = MapSetting.GetAllMaps();
 }