コード例 #1
0
        private static void ClearPackingTagAndAssetBundle()
        {
            List <string> bundlePaths = EditorResHelper.GetAllResourcePath("Assets/Bundles/", true);

            foreach (string bundlePath in bundlePaths)
            {
                SetBundle(bundlePath, "", true);
                List <string> pathes = CollectDependencies(bundlePath);

                foreach (string pt in pathes)
                {
                    if (pt == bundlePath)
                    {
                        continue;
                    }

                    SetBundleAndAtlas(pt, "", true);
                }
            }

            List <string> paths = EditorResHelper.GetAllResourcePath("Assets/Res", true);

            foreach (string pt in paths)
            {
                SetBundleAndAtlas(pt, "", true);
            }
        }
コード例 #2
0
ファイル: BuildEditor.cs プロジェクト: SendSi/SmallGame
        private static void SetRootBundleOnlyForFolder(string dir)
        {
            List <string> dirs = new List <string>();

            FileHelper.GetAllDirectories(dirs, dir);
            foreach (string s in dirs)
            {
                List <string> paths = EditorResHelper.GetPrefabsAndScenes(s);
                foreach (string path in paths)
                {
                    string path1      = path.Replace('\\', '/');
                    Object go         = AssetDatabase.LoadAssetAtPath <Object>(path1);
                    string name       = path1.Replace(dir, "");
                    int    startIndex = 0;
                    int    length     = name.LastIndexOf('.');
                    if (name[0].Equals('/'))
                    {
                        startIndex = 1;
                        length    -= 1;
                    }
                    name = name.Substring(startIndex, length);
                    SetBundle(path1, name.ToLower());
                }
            }
        }
コード例 #3
0
        // 会将目录下的每个prefab引用的资源强制打成一个包,不分析共享资源
        private static void SetIndependentBundleAndAtlas(string dir)
        {
            List <string> paths = EditorResHelper.GetPrefabsAndScenes(dir);

            foreach (string path in paths)
            {
                string path1 = path.Replace('\\', '/');
                Object go    = AssetDatabase.LoadAssetAtPath <Object>(path1);

                AssetImporter importer = AssetImporter.GetAtPath(path1);
                if (importer == null || go == null)
                {
                    Log.Error("error: " + path1);
                    continue;
                }
                importer.assetBundleName = $"{go.name}.unity3d";

                List <string> pathes = CollectDependencies(path1);

                foreach (string pt in pathes)
                {
                    if (pt == path1)
                    {
                        continue;
                    }

                    SetBundleAndAtlas(pt, go.name, true);
                }
            }
        }
コード例 #4
0
        public void StartGenerateMatFile()
        {
            List <string> innerRes = new List <string>();

            //先遍历文件夹中所有dds文件
            foreach (var VARIABLE in this.ddsFolderList)
            {
                innerRes.AddRange(EditorResHelper.GetAllDDSFilePath(VARIABLE));
            }

            //根据文件路径加载文件
            foreach (var VARIABLE in innerRes)
            {
                this.ddsFileList.Add(AssetDatabase.LoadAssetAtPath <Texture>(VARIABLE));
            }

            //使用HashSet去重
            FinalFiles = new HashSet <Texture>(this.ddsFileList);

            //正式生成
            foreach (var VARIABLE in FinalFiles)
            {
                Material materialData = new Material(this.ShaderSetting);
                materialData.mainTexture = VARIABLE;

                string   fileFullPath = AssetDatabase.GetAssetPath(VARIABLE);
                string[] pathSplit    = fileFullPath.Split('/');

                AssetDatabase.CreateAsset(materialData,
                                          string.Concat(fileFullPath.Substring(0, fileFullPath.Length - pathSplit[pathSplit.Length - 1].Length), VARIABLE.name, ".mat"));
            }
        }
コード例 #5
0
ファイル: BuildEditor.cs プロジェクト: SendSi/SmallGame
        private static void ClearPackingTagForResAtlasFolder()
        {
            List <string> paths = EditorResHelper.GetAllResourcePath("Assets/Res/Atlas", true);

            foreach (string pt in paths)
            {
                SetBundleAndAtlas(pt, "", true);
            }
        }
コード例 #6
0
        private static void SetBundleHumanTexture(string dir, bool subDir = true)
        {
            List <string> paths = EditorResHelper.GetAllResourcePath(dir, subDir);

            foreach (string path in paths)
            {
                string path1 = path.Replace('\\', '/');
                Object go    = AssetDatabase.LoadAssetAtPath <Object>(path1);
                SetBundle(path1, go.name, true);
            }
        }
コード例 #7
0
        // 分析共享资源
        private void SetShareBundleAndAtlas(string dir)
        {
            this.dictionary.Clear();
            List <string> paths = EditorResHelper.GetPrefabsAndScenes(dir);

            foreach (string path in paths)
            {
                string path1 = path.Replace('\\', '/');
                Object go    = AssetDatabase.LoadAssetAtPath <Object>(path1);

                SetBundle(path1, go.name);

                List <string> pathes = CollectDependencies(path1);
                foreach (string pt in pathes)
                {
                    if (pt == path1)
                    {
                        continue;
                    }

                    // 不存在则记录下来
                    if (!this.dictionary.ContainsKey(pt))
                    {
                        // 如果已经设置了包
                        if (GetBundleName(pt) != "")
                        {
                            continue;
                        }
                        Log.Info($"{path1}----{pt}");
                        BundleInfo bundleInfo = new BundleInfo();
                        bundleInfo.ParentPaths.Add(path1);
                        this.dictionary.Add(pt, bundleInfo);

                        SetAtlas(pt, go.name);

                        continue;
                    }

                    // 依赖的父亲不一样
                    BundleInfo info = this.dictionary[pt];
                    if (info.ParentPaths.Contains(path1))
                    {
                        continue;
                    }
                    info.ParentPaths.Add(path1);

                    DirectoryInfo dirInfo = new DirectoryInfo(dir);
                    string        dirName = dirInfo.Name;

                    SetBundleAndAtlas(pt, $"{dirName}-share", true);
                }
            }
        }
コード例 #8
0
        // 会将目录下的每个prefab引用的资源打成一个包,只给顶层prefab打包
        private static void SetRootBundleOnly(string dir)
        {
            List <string> paths = EditorResHelper.GetPrefabsAndScenes(dir);

            foreach (string path in paths)
            {
                string path1 = path.Replace('\\', '/');
                Object go    = AssetDatabase.LoadAssetAtPath <Object>(path1);

                SetBundle(path1, go.name);
            }
        }
コード例 #9
0
        /// <summary>
        /// 会将目录下的每个prefab引用的资源打成一个包,只给顶层prefab打包
        /// 包添加一个前缀路径
        /// </summary>
        /// <param name="dir"></param>
        private static void SetBundleByParentPath(string dir, string parentPathName = "ui")
        {
            List <string> paths = EditorResHelper.GetPrefabsAndScenes(dir);

            foreach (string path in paths)
            {
                string path1 = path.Replace('\\', '/');
                Object go    = AssetDatabase.LoadAssetAtPath <Object>(path1);

                SetBundle(path1, parentPathName + "/" + go.name, true);
            }
        }
コード例 #10
0
ファイル: BuildEditor.cs プロジェクト: SendSi/SmallGame
        private void SetPackingTagForCommonAtlas()
        {
            List <string> paths = EditorResHelper.GetAllResourcePath("Assets/Res/Atlas/Common", true);

            foreach (string pt in paths)
            {
                string tmp = pt.Replace('\\', '/');
                tmp = tmp.Replace("Assets/Res/Atlas/", "");
                tmp = tmp.Substring(0, tmp.IndexOf('/'));
                SetBundleAndAtlas(pt, $"atlas{tmp.ToLower()}", true);
            }
        }
コード例 #11
0
        private static void ClearPackingTagAndAssetBundle()
        {
            //List<string> bundlePaths = EditorResHelper.GetAllResourcePath("Assets/Bundles/", true);
            //foreach (string bundlePath in bundlePaths)
            //{
            //	SetBundle(bundlePath, "", true);
            //}

            List <string> paths = EditorResHelper.GetAllResourcePath("Assets/Res", true);

            foreach (string pt in paths)
            {
                SetBundleAndAtlas(pt, "", true);
            }
        }
コード例 #12
0
        private static void SetNoAtlas(string dir)
        {
            List <string> paths = EditorResHelper.GetPrefabsAndScenes(dir);

            foreach (string path in paths)
            {
                List <string> pathes = CollectDependencies(path);

                foreach (string pt in pathes)
                {
                    if (pt == path)
                    {
                        continue;
                    }

                    SetAtlas(pt, "", true);
                }
            }
        }
コード例 #13
0
        private static void SetBundleAndAtlasWithoutShare(string dir)
        {
            List <string> paths = EditorResHelper.GetPrefabsAndScenes(dir);

            foreach (string path in paths)
            {
                string path1 = path.Replace('\\', '/');
                Object go    = AssetDatabase.LoadAssetAtPath <Object>(path1);

                SetBundle(path1, go.name, true);

                //List<string> pathes = CollectDependencies(path1);
                //foreach (string pt in pathes)
                //{
                //	if (pt == path1)
                //	{
                //		continue;
                //	}
                //
                //	SetBundleAndAtlas(pt, go.name);
                //}
            }
        }