コード例 #1
0
    /// <summary>
    /// 编辑元素
    /// </summary>
    public static void ModifyElement(string folderPath, BuildSetting.EFolderPackRule packRule, BuildSetting.EBundleNameRule nameRule)
    {
        // 注意:这里强制修改忽略文件夹的命名规则为None
        if (packRule == BuildSetting.EFolderPackRule.Ignore)
        {
            nameRule = BuildSetting.EBundleNameRule.None;
        }
        else
        {
            if (nameRule == BuildSetting.EBundleNameRule.None)
            {
                nameRule = BuildSetting.EBundleNameRule.TagByFilePath;
            }
        }

        for (int i = 0; i < Setting.Elements.Count; i++)
        {
            if (Setting.Elements[i].FolderPath == folderPath)
            {
                Setting.Elements[i].PackRule = packRule;
                Setting.Elements[i].NameRule = nameRule;
                break;
            }
        }
        SaveFile();
    }
コード例 #2
0
    private void OnGUI()
    {
        // 列表显示
        EditorGUILayout.Space();
        EditorGUILayout.LabelField($"Pack Path List");
        for (int i = 0; i < BuildSettingData.Setting.Elements.Count; i++)
        {
            string folderPath = BuildSettingData.Setting.Elements[i].FolderPath;
            BuildSetting.EFolderPackRule packRule = BuildSettingData.Setting.Elements[i].PackRule;
            BuildSetting.EBundleNameRule nameRule = BuildSettingData.Setting.Elements[i].NameRule;

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(folderPath);

                BuildSetting.EFolderPackRule newPackRule = (BuildSetting.EFolderPackRule)EditorGUILayout.EnumPopup(packRule, GUILayout.MaxWidth(150));
                if (newPackRule != packRule)
                {
                    packRule = newPackRule;
                    BuildSettingData.ModifyElement(folderPath, packRule, nameRule);
                }

                BuildSetting.EBundleNameRule newNameRule = (BuildSetting.EBundleNameRule)EditorGUILayout.EnumPopup(nameRule, GUILayout.MaxWidth(150));
                if (newNameRule != nameRule)
                {
                    nameRule = newNameRule;
                    BuildSettingData.ModifyElement(folderPath, packRule, nameRule);
                }

                if (GUILayout.Button("-", GUILayout.MaxWidth(40)))
                {
                    BuildSettingData.RemoveElement(folderPath);
                    break;
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        // 添加按钮
        if (GUILayout.Button("+"))
        {
            string resultPath = EditorTools.OpenFolderPanel("+", _lastOpenFolderPath);
            if (resultPath != null)
            {
                _lastOpenFolderPath = EditorTools.AbsolutePathToAssetPath(resultPath);
                BuildSettingData.AddElement(_lastOpenFolderPath);
            }
        }
    }