private static void Init()
        {
            var window = GetWindow <CocoDressEditWindow> (TITLE, true);

            window.titleContent = new GUIContent(CocoDressEditorHelper.GetLanguageText(TITLE));
            window.minSize      = new Vector2(720, 360);
        }
        private static void LoadEditorConfig()
        {
            // load config
            var path = CocoDressEditorHelper.GetFullPath(CocoDressSettings.EditorConfigFilePath);

            m_EditConfigHolder = CocoData.LoadFromJsonFile <CocoDressEditorConfigHolder> (path);

            // fix default config
            FixEditorDefaultConfig();

            UpdateAssetFullDirectory();
        }
        private void SaveEditorConfig()
        {
            if (m_EditConfigHolder == null)
            {
                return;
            }

            var path = CocoDressEditorHelper.GetFullPath(CocoDressSettings.EditorConfigFilePath);

            CocoData.SaveToJsonFile(m_EditConfigHolder, path, true);

            AssetDatabase.Refresh();
        }
        private void DrawAssetGenerationSettings()
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            // title
            EditorGUILayout.LabelField(Text(LABEL_ASSET_GENERATE_SETTINGS), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            // config
            CocoDressEditorHelper.PathField(Text(LABEL_GLOBAL_CONFIG_PATH), ref m_EditConfigHolder.globalConfigFileName, _assetConfigFullDirectory, true);

            // settings field
            EditorGUILayout.BeginVertical(GUI.skin.box);
            m_EditConfigHolder.prettyPrint   = EditorGUILayout.Toggle(Text(LABEL_PRETTY_PRINT), m_EditConfigHolder.prettyPrint);
            m_EditConfigHolder.randomSorting = EditorGUILayout.Toggle(Text(LABEL_RANDOM_SORTING), m_EditConfigHolder.randomSorting);
            EditorGUILayout.EndVertical();

            // buttons
            EditorGUILayout.BeginHorizontal();
            if (m_AssetConfigHolder == null)
            {
                if (GUILayout.Button(Text(BUTTON_LOAD)))
                {
                    LoadAssetConfig();
                }
            }
            else
            {
                if (GUILayout.Button(Text(BUTTON_SAVE)))
                {
                    SaveAssetConfig();
                }
            }
            GUILayout.Space(20);
            if (CocoDressEditorHelper.Button(Text(BUTTON_AUTO_GENERATE), Color.red))
            {
                AutoGenerateAssetConfig();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
        }
        private void InitLanguageTexts()
        {
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, TITLE, "Coco资源编辑器");

            // editor settings
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_DIRECTORY_SETTINGS, "---- 目录设置 ----");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_ROOT_DIRECTORY, "根目录:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_ORIGIN_DIRECTORY, "原始资源目录:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_TARGET_DIRECTORY, "目标输出目录:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_CONFIG_DIRECTORY, "配置文件目录:");

            // asset settings
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_ASSET_GENERATE_SETTINGS, "---- 资源生成设置 ----");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_PRETTY_PRINT, "格式化输出:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_RANDOM_SORTING, "随机排序:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_GLOBAL_CONFIG_PATH, "全局配置文件:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_LOAD, "载入");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_SAVE, "保存");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_AUTO_GENERATE, "自动生成");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_CANCEL, "取消");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_STILL_CONTINUE, "仍然继续");

            // asset bundle settings
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_ASSET_BUNDLE_SETTINGS, "---- AssetBundle 设置 ----");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_USE_ASSET_BUNDLE, "使用AssetBundle方式:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_COMPRESS_OPTION, "压缩选项:");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_OK, "好的");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_AUTO_SET_AB_TAGS, "自动设置AssetBundle标签");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_CORRECT_AB_TAGS, "纠正AssetBundle标签设置");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, BUTTON_AUTO_GENERATE_AB, "自动生成AssetBundle");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_SELECT_EXTERNAL, "选择外部标签");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_GENERATE, "生成");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_SELECT_TARGET, "选择目标平台");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, LABEL_COPY_TO_TARGET, "拷贝到目标位置");

            // message
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, MESSAGE_TITLE_WARNING, "警告 !!");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, MESSAGE_TITLE_INFO, "信息");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, MESSAGE_CONTENT_AUTO_GENERATE, "配置数据已经存在! 仍然自动生成? (原有数据将被覆盖...)");
            CocoDressEditorHelper.SetLanguageText(SystemLanguage.Chinese, MESSAGE_CONTENT_NOT_USE_ASSET_BUNDLE, "Asset Bundle在编辑器配置在被禁用, 请启用它再继续");
        }
        private void DrawDirectorySettings()
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);

            // title
            EditorGUILayout.LabelField(Text(LABEL_DIRECTORY_SETTINGS), EditorStyles.boldLabel);
            EditorGUILayout.Space();

            // directory field
            if (CocoDressEditorHelper.PathField(Text(LABEL_ROOT_DIRECTORY), ref m_EditConfigHolder.originRootDirectory, Application.dataPath, true))
            {
                UpdateAssetFullDirectory();
            }

            CocoDressEditorHelper.PathField(Text(LABEL_ORIGIN_DIRECTORY), ref m_EditConfigHolder.assetDirectory, _rootFullDirectory, true);

            if (CocoDressEditorHelper.PathField(Text(LABEL_CONFIG_DIRECTORY), ref m_EditConfigHolder.configDirectory, _rootFullDirectory, true))
            {
                UpdateAssetFullDirectory();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
        }
Ejemplo n.º 7
0
 private string GetRelativePath(string fullPath)
 {
     return(CocoDressEditorHelper.GetRelativePath(fullPath, _rootFullDirectory));
 }
Ejemplo n.º 8
0
        private CocoAssetConfigHolder GenerateAssetConfig()
        {
            // create asset config holder
            var fullPath          = Path.Combine(_assetConfigFullDirectory, _editorConfigHolder.globalConfigFileName);
            var assetConfigHolder = new CocoAssetConfigHolder()
            {
                id        = Path.GetFileNameWithoutExtension(_editorConfigHolder.globalConfigFileName),
                assetPath = GetRelativePath(fullPath)
            };
            var allSceneDressItemIds = new Dictionary <string, Dictionary <string, HashSet <string> > > ();

            // create category holders
            var originAssetPath = Path.Combine(_rootFullDirectory, _editorConfigHolder.assetDirectory);

            originAssetPath = CocoDressEditorHelper.GetFullPath(originAssetPath);
            var categoryPaths = Directory.GetDirectories(originAssetPath);

            foreach (var path in categoryPaths)
            {
                Dictionary <string, HashSet <string> > sceneItemIds;
                var categoryHolder       = GenerateCategory(path, out sceneItemIds);
                var categoryConfigHolder = GenerateCategoryConfig(categoryHolder);

                var tItemCount = 0;
                foreach (var item in sceneItemIds.Values)
                {
                    tItemCount += item.Count;
                    if (tItemCount > 0)
                    {
                        break;
                    }
                }

                if (categoryHolder != null && tItemCount > 0)
                {
                    assetConfigHolder.categoryConfigHolders.Add(categoryConfigHolder);
                    CollectAllSceneDressItemIds(allSceneDressItemIds, sceneItemIds, categoryHolder.id);
                }
            }

            // create scene holders
            foreach (var kvpSceneDressItemIds in allSceneDressItemIds)
            {
                var sceneHolder       = GenerateScene(kvpSceneDressItemIds.Key, kvpSceneDressItemIds.Value);
                var sceneConfigHolder = GenerateSceneConfig(sceneHolder);
                if (sceneConfigHolder != null)
                {
                    assetConfigHolder.sceneConfigHolders.Add(sceneConfigHolder);
                }
            }

            // create role dress
            _editorConfigHolder.roleDressConfigHolders.ForEach(editorRoleDressConfigHolder => {
                var roleDressHolder = GenerateRoleDress(editorRoleDressConfigHolder, allSceneDressItemIds);
                if (roleDressHolder != null)
                {
                    var roleDressConfigHolder = GenerateRoleDressConfig(roleDressHolder);
                    if (roleDressConfigHolder != null)
                    {
                        assetConfigHolder.roleDressConfigHolders.Add(roleDressConfigHolder);
                    }
                }
            });


            // create role body
            _editorConfigHolder.roleBodyConfigHolders.ForEach(editorRoleBodyConfigHolder => {
                var roleBodyHolder = GenerateRoleBody(editorRoleBodyConfigHolder);
                if (roleBodyHolder != null)
                {
                    var roleBodyConfigHolder = GenerateRoleBodyConfig(roleBodyHolder);
                    if (roleBodyConfigHolder != null)
                    {
                        assetConfigHolder.roleBodyConfigHolders.Add(roleBodyConfigHolder);
                    }
                }
            });

            // create role
            _editorConfigHolder.roleConfigHolders.ForEach(editorRoleConfigHolder => {
                var roleHolder = GenerateRole(editorRoleConfigHolder);
                if (roleHolder != null)
                {
                    var roleConfigHolder = GenerateRoleConfig(roleHolder);
                    if (roleConfigHolder != null)
                    {
                        assetConfigHolder.roleConfigHolders.Add(roleConfigHolder);
                    }
                }
            });

            return(assetConfigHolder);
        }
 private string Text(string key)
 {
     return(CocoDressEditorHelper.GetLanguageText(key));
 }