コード例 #1
0
 private static Dictionary <string, LayerNode> LoadDicFromObj(ConfigBuildObj buildObj)
 {
     if (buildObj.needBuilds == null)
     {
         return(null);
     }
     else
     {
         Dictionary <string, LayerNode> nodeDic = new Dictionary <string, LayerNode>();
         LayerNode node;
         if (LayerNode.TryCreateNode(rootFolder, out node))
         {
             nodeDic.Add(rootFolder, node);
         }
         foreach (var item in buildObj.needBuilds)
         {
             RetriveAddFolder(item.assetPath, nodeDic);
             if (!nodeDic.ContainsKey(item.assetPath))
             {
                 var       path = AssetDatabase.GetAssetPath(item.obj);
                 LayerNode layernode;
                 if (LayerNode.TryCreateNode(path, out layernode))
                 {
                     nodeDic.Add(item.assetPath, layernode);
                 }
             }
         }
         return(nodeDic);
     }
 }
コード例 #2
0
 private static Dictionary <string, LayerNode> LoadDicFromObj(ConfigBuildObj buildObj)
 {
     if (buildObj.needBuilds == null)
     {
         return(null);
     }
     else
     {
         Dictionary <string, LayerNode> nodeDic = new Dictionary <string, LayerNode>();
         nodeDic.Add("Assets", new LayerNode("Assets"));
         foreach (var item in buildObj.needBuilds)
         {
             RetriveAddFolder(item.assetPath, nodeDic);
             if (!nodeDic.ContainsKey(item.assetPath))
             {
                 var path = AssetDatabase.GetAssetPath(item.obj);
                 nodeDic.Add(item.assetPath, new LayerNode(path));
             }
         }
         return(nodeDic);
     }
 }
コード例 #3
0
        private void DrawBottomTools()
        {
            var             buildObj  = target as ConfigBuildObj;
            GUIStyle        labStyle  = EditorStyles.miniBoldLabel;
            GUILayoutOption labLayout = GUILayout.Width(100);

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[目标平台]:", labStyle, labLayout);
                buildObj.buildTarget = (BuildTarget)EditorGUILayout.EnumPopup(buildObj.buildTarget);
            }
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[打包选项]:", labStyle, labLayout);
                buildObj.buildOption = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskField(buildObj.buildOption);
            }
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[清空文件]:", labStyle, labLayout);
                buildObj.clearOld = EditorGUILayout.Toggle(buildObj.clearOld);
            }

            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("生成AB(全部)", EditorStyles.toolbarDropDown))
                {
                    if (buildObj.clearOld)
                    {
                        FileUtil.DeleteFileOrDirectory(buildObj.LocalPath);
                    }

                    ConfigBuildObj bo = ScriptableObject.CreateInstance <ConfigBuildObj>();
                    StoreLayerNodeToAsset(nodeDic, bo);
                    ABBUtility.BuildGroupBundles(buildObj.LocalPath, GetBundleBuilds(buildObj.needBuilds), buildObj.buildOption, buildObj.buildTarget);
                }
                if (GUILayout.Button("生成AB(选中)", EditorStyles.toolbarDropDown))
                {
                    if (buildObj.clearOld)
                    {
                        FileUtil.DeleteFileOrDirectory(buildObj.LocalPath);
                    }

                    ConfigBuildObj bo = ScriptableObject.CreateInstance <ConfigBuildObj>();
                    StoreLayerNodeToAsset(nodeDic, bo, true);
                    ABBUtility.BuildGroupBundles(buildObj.LocalPath, GetBundleBuilds(buildObj.needBuilds), buildObj.buildOption, buildObj.buildTarget);
                }
            }
            using (var hor = new EditorGUILayout.HorizontalScope())
            {
                EditorGUILayout.LabelField("[拷贝到路径]:", GUILayout.Width(100));
                targetPath_prop.stringValue = EditorGUILayout.TextField(targetPath_prop.stringValue);
                if (GUILayout.Button("选择"))
                {
                    var path = EditorUtility.OpenFolderPanel("选择文件路径", targetPath_prop.stringValue, "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        targetPath_prop.stringValue = path;
                    }
                }
                if (GUILayout.Button("拷贝"))
                {
                    if (buildObj.LocalPath != buildObj.TargetPath && !string.IsNullOrEmpty(buildObj.TargetPath))
                    {
                        FileUtil.DeleteFileOrDirectory(buildObj.TargetPath);
                        FileUtil.CopyFileOrDirectory(buildObj.LocalPath, buildObj.TargetPath);
                    }
                }
            }
        }
コード例 #4
0
 private static void StoreLayerNodeToAsset(Dictionary <string, LayerNode> nodeDic, ConfigBuildObj buildObj, bool selectedOnly = false)
 {
     foreach (var item in nodeDic)
     {
         if (!ProjectWindowUtil.IsFolder(item.Value.layer.GetInstanceID()))
         {
             if (selectedOnly && !item.Value.selected)
             {
                 continue;
             }
             var oitem = buildObj.needBuilds.Find(x => x.obj == item.Value.layer);
             if (oitem == null)
             {
                 buildObj.needBuilds.Add(new ConfigBuildObj.ObjectItem(item.Value.layer));
             }
         }
     }
     ReFelsh(buildObj.needBuilds);
     EditorUtility.SetDirty(buildObj);
 }