public void Draw(Rect r)
 {
     GUILayout.BeginHorizontal(TableStyles.Toolbar);
     {
         isPull = GUILayout.Toggle(isPull, "PACK RULE");             //new GUIStyle{alignment = TextAnchor.MiddleCenter , normal = new GUIStyleState{textColor = new Color(1  , 1 , 1)}});
     }
     GUILayout.Space(3f);
     GUILayout.EndHorizontal();
     if (isPull)
     {
         for (int i = 0; i < config.rules.Count; i++)
         {
             OnGUIRule(config.rules[i], index == i);
             if (Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
             {
                 index = i;
                 Event.current.Use();
             }
         }
         GUILayout.BeginHorizontal(TableStyles.Toolbar);
         {
             if (GUILayout.Button("AddRule", TableStyles.ToolbarButton))
             {
                 config.rules.Add(new ABPackRuleConfig.Rule());
                 EditorUtility.SetDirty(config);
             }
             if (GUILayout.Button("Apply", TableStyles.ToolbarButton))
             {
                 BundleBuilder.ClearBundleName();
                 AutoABNamePostprocessor.PackAll();
             }
         }
         GUILayout.EndHorizontal();
     }
 }
 public static void ResetBundleNameByRule()
 {
     EditorUtility.DisplayProgressBar("重置abName", "重置abName", 1f);
     string[] assetPaths = GetAllPackAssetPath();
     for (int i = 0; i < assetPaths.Length; i++)
     {
         AssetImporter ai = AssetImporter.GetAtPath(assetPaths [i]);
         ai.assetBundleName = null;
     }
     AssetDatabase.RemoveUnusedAssetBundleNames();
     AutoABNamePostprocessor.PackAll();
 }
Пример #3
0
    private void OnGUI()
    {
        ABPackRuleConfig config = AutoABNamePostprocessor.config;

        EditorGUILayout.BeginHorizontal(GUI.skin.box);
        AutoABNamePostprocessor.autoPack = EditorGUILayout.ToggleLeft("autoPack", AutoABNamePostprocessor.autoPack);
        if (GUILayout.Button("Apply"))
        {
            AutoABNamePostprocessor.PackAll();
        }
        EditorGUILayout.EndHorizontal();
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
        int count = config.rules.Count;

        EditorGUI.BeginChangeCheck();
        for (int i = 0; i < count; i++)
        {
            OnGUIRule(config.rules[i], selectIndex == i);
            if (Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
            {
                selectIndex = i;
                Event.current.Use();
            }
        }
        if (EditorGUI.EndChangeCheck())
        {
            EditorUtility.SetDirty(config);
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Add Rule"))
        {
            config.rules.Add(new ABPackRuleConfig.Rule());
            EditorUtility.SetDirty(config);
        }
        if (count > 0 && selectIndex >= 0 && GUILayout.Button("Remove Rule"))
        {
            config.rules.RemoveAt(selectIndex);
            selectIndex = -1;
            EditorUtility.SetDirty(config);
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndScrollView();
    }