예제 #1
0
        private void Init()
        {
            _asset       = new AssetInfo(Application.dataPath, "Assets", true);
            _validAssets = new List <AssetInfo>();
            AssetBundleTool.ReadAssetsInChildren(_asset, _validAssets);

            _assetBundle = new AssetBundleInfo();
            AssetBundleTool.ReadAssetBundleConfig(_assetBundle, _validAssets);

            _buildPath = AssetBundleTool.EditorConfigInfo.BuildPath;
            List <int> buildTargets = AssetBundleTool.EditorConfigInfo.BuildTargets;

            string[] buildTargtNames = Enum.GetNames(typeof(BuildTarget));
            for (int i = 0; i < buildTargtNames.Length; i++)
            {
                BuildTarget target = (BuildTarget)Enum.Parse(typeof(BuildTarget), (buildTargtNames[i]));
                _buildTargets.Add(buildTargtNames[i], buildTargets.Contains((int)target));
            }
            //z = (BuildTarget) AssetBundleTool.EditorConfigInfo.BuildTarget;
            _zipMode      = (ZipMode)AssetBundleTool.EditorConfigInfo.ZipMode;
            _encryptMode  = (EncryptMode)AssetBundleTool.EditorConfigInfo.EncryptMode;
            _assetVersion = AssetBundleTool.EditorConfigInfo.AssetVersion;

            Resources.UnloadUnusedAssets();
        }
예제 #2
0
        private void AssetGUI(AssetInfo asset, int indentation)
        {
            if (_hideInvalidAsset && asset.AssetFileType == FileType.InValidFile)
            {
                return;
            }
            if (_hideBundleAsset && asset.Bundled != "")
            {
                return;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(indentation * 20 + 5);
            if (asset.AssetFileType == FileType.Folder)
            {
                if (GUILayout.Toggle(asset.IsChecked, "", GUILayout.Width(20)) != asset.IsChecked)
                {
                    AssetBundleTool.ChangeCheckedInChildren(asset, !asset.IsChecked);
                }

                GUIContent content = EditorGUIUtility.IconContent("Folder Icon");
                content.text      = asset.AssetName;
                asset.IsExpanding = EditorGUILayout.Foldout(asset.IsExpanding, content);
            }
            else
            {
                GUI.enabled = !(asset.AssetFileType == FileType.InValidFile || asset.Bundled != "");
                if (GUILayout.Toggle(asset.IsChecked, "", GUILayout.Width(20)) != asset.IsChecked)
                {
                    AssetBundleTool.ChangeCheckedInChildren(asset, !asset.IsChecked);
                }

                GUILayout.Space(10);
                GUIContent content = EditorGUIUtility.ObjectContent(null, asset.AssetType);
                content.text = asset.AssetName;
                GUILayout.Label(content, GUILayout.Height(20));
                GUI.enabled = true;

                if (asset.Bundled != "")
                {
                    GUILayout.Label("[" + asset.Bundled + "]", _prefabLabel);
                }
            }
            _assetViewHeight += 20;
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (asset.IsExpanding)
            {
                for (int i = 0; i < asset.ChildAssetInfo.Count; i++)
                {
                    AssetGUI(asset.ChildAssetInfo[i], indentation + 1);
                }
            }
        }
예제 #3
0
 /// <summary>
 /// 文件类型资源
 /// </summary>
 public AssetInfo(string fullPath, string name, string extension)
 {
     AssetFullPath  = fullPath;
     AssetPath      = "Assets" + fullPath.Replace(Application.dataPath.Replace("/", "\\"), "");
     AssetName      = name;
     GUID           = AssetDatabase.AssetPathToGUID(AssetPath);
     AssetFileType  = AssetBundleTool.GetFileTypeByExtension(extension);
     AssetType      = AssetDatabase.LoadMainAssetAtPath(AssetPath).GetType();
     IsChecked      = false;
     IsExpanding    = false;
     Bundled        = "";
     ChildAssetInfo = null;
 }
예제 #4
0
        private void SettingGUI()
        {
            if (_showSetting)
            {
                GUI.BeginGroup(new Rect((int)position.width / 2 - 125, (int)position.height / 2 - 65, 250, 130), "", _flownode0on);

                GUI.Label(new Rect(5, 5, 80, 20), "Build Target: ");
                BuildTarget buildTarget = (BuildTarget)EditorGUI.EnumPopup(new Rect(90, 5, 155, 20), _buildTarget, _preDropDown);
                if (buildTarget != _buildTarget)
                {
                    _buildTarget = buildTarget;
                    AssetBundleTool.EditorConfigInfo.BuildTarget = (int)_buildTarget;
                    AssetBundleTool.SaveEditorConfigInfo();
                }

                GUI.Label(new Rect(5, 30, 80, 20), "Zip Mode: ");
                ZipMode zipMode = (ZipMode)EditorGUI.EnumPopup(new Rect(90, 30, 155, 20), _zipMode, _preDropDown);
                if (zipMode != _zipMode)
                {
                    _zipMode = zipMode;
                    AssetBundleTool.EditorConfigInfo.ZipMode = (int)_zipMode;
                    AssetBundleTool.SaveEditorConfigInfo();
                }

                GUI.Label(new Rect(5, 55, 80, 20), "Encrypt: ");
                EncryptMode encryptMode = (EncryptMode)EditorGUI.EnumPopup(new Rect(90, 55, 155, 20), _encryptMode, _preDropDown);
                if (encryptMode != _encryptMode)
                {
                    _encryptMode = encryptMode;
                    AssetBundleTool.EditorConfigInfo.EncryptMode = (int)encryptMode;
                    AssetBundleTool.SaveEditorConfigInfo();
                }

                GUI.Label(new Rect(5, 80, 150, 20), "Asset Version: " + _assetVersion);
                if (GUI.Button(new Rect(150, 80, 95, 20), "Reset", _preButton))
                {
                    _assetVersion = 1;
                    AssetBundleTool.EditorConfigInfo.AssetVersion = _assetVersion;
                    AssetBundleTool.SaveEditorConfigInfo();
                }

                if (GUI.Button(new Rect(100, 105, 50, 20), "Sure", _preButton))
                {
                    _showSetting = false;
                }

                GUI.EndGroup();
            }
        }
예제 #5
0
        private void Init()
        {
            _asset       = new AssetInfo(Application.dataPath, "Assets", true);
            _validAssets = new List <AssetInfo>();
            AssetBundleTool.ReadAssetsInChildren(_asset, _validAssets);

            _assetBundle = new AssetBundleInfo();
            AssetBundleTool.ReadAssetBundleConfig(_assetBundle, _validAssets);

            _buildPath    = AssetBundleTool.EditorConfigInfo.BuildPath;
            _buildTarget  = (BuildTarget)AssetBundleTool.EditorConfigInfo.BuildTarget;
            _zipMode      = (ZipMode)AssetBundleTool.EditorConfigInfo.ZipMode;
            _encryptMode  = (EncryptMode)AssetBundleTool.EditorConfigInfo.EncryptMode;
            _assetVersion = AssetBundleTool.EditorConfigInfo.AssetVersion;

            Resources.UnloadUnusedAssets();
        }
예제 #6
0
        private void SettingGUI()
        {
            if (_showSetting)
            {
                int width = 325, height = 290;

                GUI.BeginGroup(new Rect((int)position.width / 2 - width / 2, (int)position.height / 2 - height / 2, width, height), "", _flownode0on);
                //-----------Build Target
                GUI.Label(new Rect(5, 5, 100, 20), "Build Target:", "HeaderLabel");
                GUI.BeginGroup(new Rect(5, 25, 315, 135), _box);
                // string[] buildTargets = Enum.GetNames(typeof(BuildTarget));
                _buildTargetScrollView = GUI.BeginScrollView(new Rect(0, 2, 313, 132), _buildTargetScrollView,
                                                             new Rect(0, 0, 180, 20 * _buildTargets.Count), false, true);
                int index = 0;
                foreach (var item in _buildTargets)
                {
                    bool value = GUI.Toggle(new Rect(5, 20 * index, 180, 20), item.Value, item.Key);
                    if (value != item.Value)
                    {
                        _buildTargets[item.Key] = value;
                        break;
                    }
                    index++;
                }
                GUI.EndScrollView();
                GUI.EndGroup();
                //--------Zip Mode
                GUI.Label(new Rect(5, 165, 60, 20), "Zip Mode:", "HeaderLabel");
                ZipMode zipMode = (ZipMode)EditorGUI.EnumPopup(new Rect(75, 165, 240, 20), _zipMode, _preDropDown);
                if (zipMode != _zipMode)
                {
                    _zipMode = zipMode;
                    AssetBundleTool.EditorConfigInfo.ZipMode = (int)_zipMode;
                    AssetBundleTool.SaveEditorConfigInfo();
                }
                //----------Encrypt
                GUI.Label(new Rect(5, 190, 60, 20), "Encrypt: ", "HeaderLabel");
                EncryptMode encryptMode = (EncryptMode)EditorGUI.EnumPopup(new Rect(75, 190, 240, 20), _encryptMode, _preDropDown);
                if (encryptMode != _encryptMode)
                {
                    _encryptMode = encryptMode;
                    AssetBundleTool.EditorConfigInfo.EncryptMode = (int)encryptMode;
                    AssetBundleTool.SaveEditorConfigInfo();
                }
                // ----------Assets Version
                GUI.Label(new Rect(5, 215, 150, 20), "Asset Version: " + _assetVersion, "HeaderLabel");
                if (GUI.Button(new Rect(160, 215, 95, 20), "Reset", _preButton))
                {
                    _assetVersion = 1;
                    AssetBundleTool.EditorConfigInfo.AssetVersion = _assetVersion;
                    AssetBundleTool.SaveEditorConfigInfo();
                }
                //sure cancel
                if (GUI.Button(new Rect(92.5f, 255, 140, 20), "Sure", _preButton))
                {
                    //更新目标平台
                    foreach (var item in _buildTargets)
                    {
                        BuildTarget target  = (BuildTarget)Enum.Parse(typeof(BuildTarget), (item.Key));
                        int         iTarget = (int)target;
                        if (item.Value)
                        {
                            if (!AssetBundleTool.EditorConfigInfo.BuildTargets.Contains(iTarget))
                            {
                                AssetBundleTool.EditorConfigInfo.BuildTargets.Add(iTarget);
                            }
                        }
                        else
                        {
                            if (AssetBundleTool.EditorConfigInfo.BuildTargets.Contains(iTarget))
                            {
                                AssetBundleTool.EditorConfigInfo.BuildTargets.Remove(iTarget);
                            }
                        }
                    }
                    //保存配置文件
                    AssetBundleTool.SaveEditorConfigInfo();

                    _showSetting = false;
                }
                //if (GUI.Button(new Rect(175, 255, 140, 20), "Cancel", _preButton))
                //{
                //    _showSetting = false;
                //}
                GUI.EndGroup();
            }
        }
예제 #7
0
        private void TitleGUI()
        {
            if (GUI.Button(new Rect(5, 5, 60, 15), "Create", _preButton))
            {
                AssetBundleBuildInfo build = new AssetBundleBuildInfo("ab" + System.DateTime.Now.ToString("yyyyMMddHHmmss"));
                _assetBundle.AssetBundles.Add(build);
            }

            GUI.enabled = _currentAB == -1 ? false : true;
            if (GUI.Button(new Rect(65, 5, 60, 15), "Rename", _preButton))
            {
                _isRename = !_isRename;
            }
            if (GUI.Button(new Rect(125, 5, 60, 15), "Clear", _preButton))
            {
                if (EditorUtility.DisplayDialog("Prompt", "Clear " + _assetBundle.AssetBundles[_currentAB].Name + " ?", "Yes", "No"))
                {
                    _assetBundle.AssetBundles[_currentAB].ClearAsset();
                }
            }
            if (GUI.Button(new Rect(185, 5, 60, 15), "Delete", _preButton))
            {
                if (EditorUtility.DisplayDialog("Prompt", "Delete " + _assetBundle.AssetBundles[_currentAB].Name + "?This will clear all assets!", "Yes", "No"))
                {
                    _assetBundle.DeleteAssetBundle(_currentAB);
                    _currentAB = -1;
                }
            }
            if (GUI.Button(new Rect(250, 5, 100, 15), "Add Assets", _preButton))
            {
                List <AssetInfo> assets = _validAssets.GetCheckedAssets();
                for (int i = 0; i < assets.Count; i++)
                {
                    _assetBundle.AssetBundles[_currentAB].AddAsset(assets[i]);
                }
            }
            GUI.enabled = true;

            if (GUI.Button(new Rect(250, 25, 60, 15), "Open", _preButton))
            {
                AssetBundleTool.OpenFolder(_buildPath);
            }
            if (GUI.Button(new Rect(310, 25, 60, 15), "Browse", _preButton))
            {
                string path = EditorUtility.OpenFolderPanel("Select Path", Application.dataPath, "");
                if (path.Length != 0)
                {
                    _buildPath = path;
                    AssetBundleTool.EditorConfigInfo.BuildPath = _buildPath;
                    AssetBundleTool.SaveEditorConfigInfo();
                }
            }

            GUI.Label(new Rect(370, 25, 70, 15), "Build Path:");
            _buildPath = GUI.TextField(new Rect(440, 25, 300, 15), _buildPath);

            if (GUI.Button(new Rect(250, 45, 100, 15), "Expand All", _preButton))
            {
                AssetBundleTool.ExpandFolder(_asset, true);
            }
            if (GUI.Button(new Rect(350, 45, 100, 15), "Shrink All", _preButton))
            {
                AssetBundleTool.ExpandFolder(_asset, false);
            }

            _hideInvalidAsset = GUI.Toggle(new Rect(460, 45, 100, 15), _hideInvalidAsset, "Hide Invalid");
            _hideBundleAsset  = GUI.Toggle(new Rect(560, 45, 100, 15), _hideBundleAsset, "Hide Bundled");

            _showSetting = GUI.Toggle(new Rect((int)position.width - 135, 5, 80, 15), _showSetting, "Setting", _preButton);

            if (GUI.Button(new Rect((int)position.width - 55, 5, 50, 15), "Build", _preButton))
            {
                AssetBundleTool.BuildAssetBundles();
            }
        }