Exemple #1
0
    /// <summary>
    ///     <para> 打包冗余资源 </para>
    /// </summary>
    static void ReimportRedundance()
    {
        // 收集冗余资源
        Dictionary <string, HashSet <string> > assets = CollectionAssetBundle.CollectionRedundance();

        Dictionary <string, List <string> > paths = new Dictionary <string, List <string> >();
        {
            var iter = assets.GetEnumerator();
            while (iter.MoveNext())
            {
                string name = iter.Current.Key;
                if (name.EndsWith(".shader"))
                {
                    continue;
                }

                string path = name.Substring(0, name.LastIndexOf("/"));

                if (!paths.TryGetValue(path, out List <string> files))
                {
                    files = new List <string>();
                    paths.Add(path, files);
                }

                files.Add(name);
            }
        }

        {
            var iter = paths.GetEnumerator();
            while (iter.MoveNext())
            {
                foreach (string file in iter.Current.Value)
                {
                    string abName = iter.Current.Key.Replace("Assets/", "");
                    if (file.EndsWith(".mat") && !file.EndsWith("_Material.mat"))
                    {
                        abName += "_mat";
                    }
                    else if (file.EndsWith("FBX"))
                    {
                        abName += "_model";
                    }

                    // 动作只能打到角色对应的ab包,测试中发现,有些特效也依赖动作,暂时先不处理动作相关的
                    if (abName.ToLower().StartsWith("data/units/hero"))
                    {
                        continue;
                    }

                    Reimport(file, abName);
                }
            }
        }
    }
Exemple #2
0
    // 冗余资源
    static void ReimportRedundance()
    {
        // 收集冗余资源
        Dictionary <string, HashSet <string> > assets = CollectionAssetBundle.CollectionRedundance();

        Dictionary <string, List <string> > paths = new Dictionary <string, List <string> >();
        {
            var iter = assets.GetEnumerator();
            while (iter.MoveNext())
            {
                string name = iter.Current.Key;
                if (name.EndsWith(".shader"))
                {
                    continue;
                }

                string        path  = name.Substring(0, name.LastIndexOf("/"));
                List <string> files = null;
                if (!paths.TryGetValue(path, out files))
                {
                    files = new List <string>();
                    paths.Add(path, files);
                }

                files.Add(name);
            }
        }

        {
            var iter = paths.GetEnumerator();
            while (iter.MoveNext())
            {
                foreach (string file in iter.Current.Value)
                {
                    string abName = iter.Current.Key.Replace("Assets/", "");
                    Reimport(file, abName);
                }
            }
        }
    }