private void AddConfigUnit(string fullPath, ABConfigUnit unit)
 {
     fullPath = fullPath.Replace("\\", "/");
     if (m_ConfigMap.ContainsKey(fullPath))
     {
         return;
     }
     m_ConfigMap.Add(fullPath, unit);
 }
        public void AddConfig(string folderFullPath)
        {
            folderFullPath = folderFullPath.Replace("\\", "/");
            ABConfigUnit unit = null;

            if (!m_ConfigMap.TryGetValue(folderFullPath, out unit))
            {
                unit = new ABConfigUnit();
                AddConfigUnit(folderFullPath, unit);
            }

            unit.folderAssetPath = EditorUtils.ABSPath2AssetsPath(folderFullPath);
        }
Beispiel #3
0
        private void DrawGUIData(ABFolderInfo info)
        {
            Rect rt = GUILayoutUtility.GetRect(800, 20, m_Style);

            rt.x += (16 * EditorGUI.indentLevel);

            using (var h = new EditorGUILayout.HorizontalScope())
            {
                if (info.childFolderInfo != null)
                {
                    rt.width = 20;
                    //EditorGUI.DrawRect(rt, Color.white);
                    if (info.isOpen)
                    {
                        if (GUI.Button(rt, m_TrangleDownIcon, m_Style))
                        {
                            info.isOpen = !info.isOpen;
                        }
                    }
                    else
                    {
                        if (GUI.Button(rt, m_TrangleRightIcon, m_Style))
                        {
                            info.isOpen = !info.isOpen;
                        }
                    }
                }

                rt.x += 20;

                GUI.Label(rt, m_FolderIcon, m_Style);
                rt.x    += 20;
                rt.width = 120;
                m_Style.normal.textColor = Color.white;
                GUI.Label(rt, info.folderName);

                ABConfigUnit configUnit   = m_Mgr.GetConfigUnit(info.folderFullPath);
                bool         isFolderFlag = true;

                if (configUnit != null)
                {
                    isFolderFlag = configUnit.isFolderFlag;
                }

                if (configUnit != null)
                {
                    rt.x += 120;
                    if (configUnit.isFolderFlag)
                    {
                        configUnit.isFolderFlag = GUI.Toggle(rt, configUnit.isFolderFlag, "文件夹模式");
                    }
                    else
                    {
                        configUnit.isFolderFlag = GUI.Toggle(rt, configUnit.isFolderFlag, "文件模式");
                    }
                }


                ABStateUnit stateUnit = m_Mgr.GetStateUnit(info.folderFullPath);

                if (stateUnit != null)
                {
                    rt.x    += 120;
                    rt.width = 160;

                    string stateMsg = null;
                    if (ABState2Msg(stateUnit.state, out stateMsg))
                    {
                        if (isFolderFlag != stateUnit.state.isFolderFlag && !stateUnit.state.isNoneFlag)
                        {
                            m_Style.normal.textColor = Color.red;
                        }
                        else
                        {
                            m_Style.normal.textColor = Color.gray;
                        }

                        stateMsg = string.Format("当前状态:{0}", stateMsg);
                        GUI.Label(rt, stateMsg, m_Style);

                        rt.x += 180;
                        if (GUI.Button(rt, "重置"))
                        {
                            m_Mgr.FixedFolder(stateUnit.folderAssetPath);
                        }
                    }
                    else
                    {
                        m_Style.normal.textColor = Color.red;
                        stateMsg = string.Format("当前状态:{0}", stateMsg);
                        GUI.Label(rt, stateMsg, m_Style);

                        rt.x += 180;
                        if (GUI.Button(rt, "修复"))
                        {
                            m_Mgr.FixedFolder(stateUnit.folderAssetPath);
                        }
                    }

                    rt.x += 180;
                    if (GUI.Button(rt, "构建AB"))
                    {
                        AssetBundleExporter.BuildAssetBundlesInSelectFolder(stateUnit.folderAssetPath);
                    }
                }
            }
        }
Beispiel #4
0
        private void AutoGenAssetNameInFolder(string folderPath)
        {
            if (folderPath == null)
            {
                Log.w("Folder Path Is Null!");
                return;
            }

            Log.i("Start Set Asset Name. Folder:" + folderPath);
            string workPath        = EditorUtils.AssetsPath2ABSPath(folderPath).Replace("\\", "/"); //EditUtils.GetFullPath4AssetsPath(folderPath);
            string assetBundleName = EditorUtils.AssetPath2ReltivePath(folderPath).ToLower();       //EditUtils.GetReltivePath4AssetPath(folderPath).ToLower();

            assetBundleName = assetBundleName.Replace("resources/", "");
            //处理文件
            var filePaths = Directory.GetFiles(workPath);

            ABConfigUnit configUnit   = GetConfigUnit(workPath);
            bool         isFolderFlag = true;

            if (configUnit != null)
            {
                isFolderFlag = configUnit.isFolderFlag;
            }

            for (int i = 0; i < filePaths.Length; ++i)
            {
                if (!AssetFileFilter.IsAsset(filePaths[i]))
                {
                    continue;
                }

                string fileName = Path.GetFileName(filePaths[i]);

                string fullFileName = string.Format("{0}/{1}", folderPath, fileName);

                AssetImporter ai = AssetImporter.GetAtPath(fullFileName);
                if (ai == null)
                {
                    Log.e("Not Find Asset:" + fullFileName);
                    continue;
                }
                else
                {
                    if (isFolderFlag)
                    {
                        ai.assetBundleName = assetBundleName + ".bundle";
                    }
                    else
                    {
                        ai.assetBundleName = string.Format("{0}/{1}.bundle", assetBundleName, PathHelper.FileNameWithoutSuffix(fileName));
                    }
                }

                //ai.SaveAndReimport();
                //Log.i("Success Process Asset:" + fileName);
            }

            //递归处理文件夹
            var dirs = Directory.GetDirectories(workPath);

            for (int i = 0; i < dirs.Length; ++i)
            {
                string fileName = Path.GetFileName(dirs[i]);

                fileName = string.Format("{0}/{1}", folderPath, fileName);
                AutoGenAssetNameInFolder(fileName);
            }
        }