Example #1
0
        void OnListElementGUI(Rect rect, int index, bool isactive, bool isfocused)
        {
            const float GAP = 5;

            AssetBundleFilter filter = _config.filters[index];

            rect.y++;

            Rect r = rect;

            r.width      = 16;
            r.height     = 18;
            filter.valid = GUI.Toggle(r, filter.valid, GUIContent.none);

            r.xMin      = r.xMax + GAP;
            r.xMax      = rect.xMax - 300;
            GUI.enabled = false;
            filter.path = GUI.TextField(r, filter.path);
            GUI.enabled = true;

            r.xMin  = r.xMax + GAP;
            r.width = 50;
            if (GUI.Button(r, "Select"))
            {
                string dataPath     = Application.dataPath;
                string selectedPath = EditorUtility.OpenFolderPanel("Path", dataPath, "");
                if (!string.IsNullOrEmpty(selectedPath))
                {
                    if (selectedPath.StartsWith(dataPath))
                    {
                        filter.path = "Assets/" + selectedPath.Substring(dataPath.Length + 1);
                    }
                    else
                    {
                        ShowNotification(new GUIContent("不能在Assets目录之外!"));
                    }
                }
            }

            r.xMin        = r.xMax + GAP;
            r.xMax        = rect.xMax;
            filter.filter = GUI.TextField(r, filter.filter);
        }
Example #2
0
        void OnListElementGUI(Rect rect, int index, bool isactive, bool isfocused)
        {
            const float GAP = 5;

            AssetBundleFilter filter = _config.filters[index];

            rect.y++;

            Rect r = rect;

            r.width      = 16;
            r.height     = 18;
            filter.valid = GUI.Toggle(r, filter.valid, GUIContent.none);

            r.xMin      = r.xMax + GAP;
            r.xMax      = rect.xMax - 300;
            GUI.enabled = false;
            filter.path = GUI.TextField(r, filter.path);
            GUI.enabled = true;

            r.xMin  = r.xMax + GAP;
            r.width = 50;
            if (GUI.Button(r, "Select"))
            {
                var path = SelectFolder();
                if (path != null)
                {
                    filter.path = path;
                }
            }
            r.xMin          = r.xMax + GAP;
            r.width         = 80;
            filter.packMode = (PackMode)EditorGUI.EnumPopup(r, filter.packMode);

            r.xMin        = r.xMax + GAP;
            r.xMax        = rect.xMax;
            filter.filter = GUI.TextField(r, filter.filter);
        }
        void OnGUI()
        {
            bool execBuild = false;

            if (config == null)
            {
                config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
                if (config == null)
                {
                    config = new AssetBundleBuildConfig();
                }
            }

            UpdateStyles();
            //tool bar
            GUILayout.BeginHorizontal(Styles.toolbar);
            {
                if (GUILayout.Button("Add", Styles.toolbarButton))
                {
                    config.filters.Add(new AssetBundleFilter());
                }
                if (GUILayout.Button("Save", Styles.toolbarButton))
                {
                    Save();
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Build", Styles.toolbarButton))
                {
                    execBuild = true;
                }
            }
            GUILayout.EndHorizontal();

            //context
            GUILayout.BeginVertical();

            //format
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("DepInfoFileFormat");
                config.depInfoFileFormat = (AssetBundleBuildConfig.Format)EditorGUILayout.EnumPopup(config.depInfoFileFormat);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            for (int i = 0; i < config.filters.Count; i++)
            {
                AssetBundleFilter filter = config.filters[i];
                GUILayout.BeginHorizontal();
                {
                    filter.valid = GUILayout.Toggle(filter.valid, "", GUILayout.ExpandWidth(false));

                    GUI.enabled = false;
                    filter.path = GUILayout.TextField(filter.path, GUILayout.ExpandWidth(true));
                    GUI.enabled = true;

                    if (GUILayout.Button("Select", GUILayout.ExpandWidth(false)))
                    {
                        string dataPath     = Application.dataPath;
                        string selectedPath = EditorUtility.OpenFolderPanel("Path", dataPath, "");
                        if (!string.IsNullOrEmpty(selectedPath))
                        {
                            if (selectedPath.StartsWith(dataPath))
                            {
                                filter.path = "Assets/" + selectedPath.Substring(dataPath.Length + 1);
                            }
                            else
                            {
                                ShowNotification(new GUIContent("不能在Assets目录之外!"));
                            }
                        }
                    }
                    filter.filter = GUILayout.TextField(filter.filter, GUILayout.Width(200));
                    if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                    {
                        config.filters.RemoveAt(i);
                        i--;
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();

            //set dirty
            if (GUI.changed)
            {
                EditorUtility.SetDirty(config);
            }

            if (execBuild)
            {
                Build();
            }
        }