Inheritance: UnityEngine.ScriptableObject
Exemple #1
0
        static void BuildAssetBundles()
        {
            AssetBundleBuildConfig config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);

            if (config == null)
            {
                return;
            }

#if UNITY_5 || UNITY_5_6_OR_NEWER
            ABBuilder builder = new AssetBundleBuilder5x(new AssetBundlePathResolver());
#else
            ABBuilder builder = new AssetBundleBuilder4x(new AssetBundlePathResolver());
#endif
            builder.SetDataWriter(config.depInfoFileFormat == AssetBundleBuildConfig.Format.Text ? new AssetBundleDataWriter() : new AssetBundleDataBinaryWriter());

            builder.Begin();

            for (int i = 0; i < config.filters.Count; i++)
            {
                AssetBundleFilter f = config.filters[i];
                if (f.valid)
                {
                    builder.AddRootTargets(new DirectoryInfo(f.path), new string[] { f.filter });
                }
            }

            builder.Export();
            builder.End();
        }
        static void BuildAssetBundles()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                Debug.LogError("Exit play mode before build AssetBundle!");
                return;
            }
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
            AssetBundleBuildConfig config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);

            if (config == null)
            {
                return;
            }

            ABBuilder builder = new AssetBundleBuilder5x(new AssetBundlePathResolver());

            builder.SetDataWriter(config.depInfoFileFormat == AssetBundleBuildConfig.Format.Text ? new AssetBundleDataWriter() : new AssetBundleDataBinaryWriter());

            builder.Begin();

            for (int i = 0; i < config.filters.Count; i++)
            {
                AssetBundleFilter f = config.filters[i];
                if (f.valid)
                {
                    builder.AddRootTargets(new DirectoryInfo(f.path), f.packMode, f.filter);
                }
            }
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
            builder.Export();
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
            builder.End();
            AssetBundleManager.Log("building... cur Time " + Time.realtimeSinceStartup);
        }
Exemple #3
0
 void InitConfig()
 {
     _config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
     if (_config == null)
     {
         _config = new AssetBundleBuildConfig();
     }
 }
Exemple #4
0
 void InitConfig()
 {
     _config = LoadAssetAtPath <AssetBundleBuildConfig>(savePath);
     if (_config == null)
     {
         _config = CreateInstance <AssetBundleBuildConfig>();
     }
 }
        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();
            }
        }
        void OnGUI()
        {
            bool execBuild = false;

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

            if (_list == null)
            {
                _list = new ReorderableList(_config.filters, typeof(AssetBundleFilter));
                _list.drawElementCallback = OnListElementGUI;
                _list.drawHeaderCallback  = OnListHeaderGUI;
                _list.draggable           = true;
                _list.elementHeight       = 22;
            }

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

            //context
            GUILayout.BeginVertical();

            scollbarPos = GUILayout.BeginScrollView(scollbarPos, "HiddenScrollbar", "verticalscrollbar");

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

            GUILayout.Space(10);

            _list.DoLayoutList();

            GUILayout.EndScrollView();
            GUILayout.EndVertical();

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

            if (execBuild)
            {
                Build();
            }
        }