示例#1
0
        private void ReadAssets()
        {
            Logger.Info("Read assets...");

            var progressCount = assetsFileList.Sum(x => x.m_Objects.Count);
            int i             = 0;

            Progress.Reset();
            foreach (var assetsFile in assetsFileList)
            {
                assetsFile.Objects = new Dictionary <long, Object>(assetsFile.m_Objects.Count);
                foreach (var objectInfo in assetsFile.m_Objects)
                {
                    var objectReader = new ObjectReader(assetsFile.reader, assetsFile, objectInfo);
                    try
                    {
                        Object obj;
                        switch (objectReader.type)
                        {
                        case ClassIDType.Animation:
                            obj = new Animation(objectReader);
                            break;

                        case ClassIDType.AnimationClip:
                            obj = new AnimationClip(objectReader);
                            break;

                        case ClassIDType.Animator:
                            obj = new Animator(objectReader);
                            break;

                        case ClassIDType.AnimatorController:
                            obj = new AnimatorController(objectReader);
                            break;

                        case ClassIDType.AnimatorOverrideController:
                            obj = new AnimatorOverrideController(objectReader);
                            break;

                        case ClassIDType.AssetBundle:
                            obj = new AssetBundle(objectReader);
                            break;

                        case ClassIDType.AudioClip:
                            obj = new AudioClip(objectReader);
                            break;

                        case ClassIDType.Avatar:
                            obj = new Avatar(objectReader);
                            break;

                        case ClassIDType.Font:
                            obj = new Font(objectReader);
                            break;

                        case ClassIDType.GameObject:
                            obj = new GameObject(objectReader);
                            break;

                        case ClassIDType.Material:
                            obj = new Material(objectReader);
                            break;

                        case ClassIDType.Mesh:
                            obj = new Mesh(objectReader);
                            break;

                        case ClassIDType.MeshFilter:
                            obj = new MeshFilter(objectReader);
                            break;

                        case ClassIDType.MeshRenderer:
                            obj = new MeshRenderer(objectReader);
                            break;

                        case ClassIDType.MonoBehaviour:
                            obj = new MonoBehaviour(objectReader);
                            break;

                        case ClassIDType.MonoScript:
                            obj = new MonoScript(objectReader);
                            break;

                        case ClassIDType.MovieTexture:
                            obj = new MovieTexture(objectReader);
                            break;

                        case ClassIDType.PlayerSettings:
                            obj = new PlayerSettings(objectReader);
                            break;

                        case ClassIDType.RectTransform:
                            obj = new RectTransform(objectReader);
                            break;

                        case ClassIDType.Shader:
                            obj = new Shader(objectReader);
                            break;

                        case ClassIDType.SkinnedMeshRenderer:
                            obj = new SkinnedMeshRenderer(objectReader);
                            break;

                        case ClassIDType.Sprite:
                            obj = new Sprite(objectReader);
                            break;

                        case ClassIDType.SpriteAtlas:
                            obj = new SpriteAtlas(objectReader);
                            break;

                        case ClassIDType.TextAsset:
                            obj = new TextAsset(objectReader);
                            break;

                        case ClassIDType.Texture2D:
                            obj = new Texture2D(objectReader);
                            break;

                        case ClassIDType.Transform:
                            obj = new Transform(objectReader);
                            break;

                        case ClassIDType.VideoClip:
                            obj = new VideoClip(objectReader);
                            break;

                        default:
                            obj = new Object(objectReader);
                            break;
                        }
                        assetsFile.Objects.Add(objectInfo.m_PathID, obj);
                    }
                    catch (Exception e)
                    {
                        /*var sb = new StringBuilder();
                         * sb.AppendLine("Unable to load object")
                         *  .AppendLine($"Assets {assetsFile.fileName}")
                         *  .AppendLine($"Type {objectReader.type}")
                         *  .AppendLine($"PathID {objectInfo.m_PathID}")
                         *  .Append(e);
                         * Logger.Error(sb.ToString());*/
                    }

                    Progress.Report(++i, progressCount);
                }
            }
        }
示例#2
0
        private void ReadAssets()
        {
            Logger.Info("Read assets...");

            var progressCount = assetsFileList.Sum(x => x.m_Objects.Count);
            int i             = 0;

            Progress.Reset();
            foreach (var assetsFile in assetsFileList)
            {
                foreach (var objectInfo in assetsFile.m_Objects)
                {
                    var objectReader = new ObjectReader(assetsFile.reader, assetsFile, objectInfo);
                    try
                    {
                        Object obj;
                        switch (objectReader.type)
                        {
                        case ClassIDType.Animation:
                            obj = new Animation(objectReader);
                            break;

                        case ClassIDType.AnimationClip:
                            obj = new AnimationClip(objectReader);
                            break;

                        case ClassIDType.Animator:
                            obj = new Animator(objectReader);
                            break;

                        case ClassIDType.AnimatorController:
                            obj = new AnimatorController(objectReader);
                            break;

                        case ClassIDType.AnimatorOverrideController:
                            obj = new AnimatorOverrideController(objectReader);
                            break;

                        case ClassIDType.AssetBundle:
                            obj = new AssetBundle(objectReader);
                            break;

                        case ClassIDType.AudioClip:
                            obj = new AudioClip(objectReader);
                            break;

                        case ClassIDType.Avatar:
                            obj = new Avatar(objectReader);
                            break;

                        case ClassIDType.Font:
                            obj = new Font(objectReader);
                            break;

                        case ClassIDType.GameObject:
                            obj = new GameObject(objectReader);
                            break;

                        case ClassIDType.Material:
                            obj = new Material(objectReader);

                            Material mat    = (obj as Material);
                            string   abName = obj.assetsFile.originalPath.Substring(obj.assetsFile.originalPath.LastIndexOf('\\') + 1);
                            string   dicKey = abName + "/" + mat.m_Name + ".mat";
                            if (!matShaderPathDict.ContainsKey(dicKey))
                            {
                                matShaderPathDict.Add(dicKey, (obj as Material).m_Shader.m_PathID);
                            }
                            break;

                        case ClassIDType.Mesh:
                            obj = new Mesh(objectReader);
                            break;

                        case ClassIDType.MeshFilter:
                            obj = new MeshFilter(objectReader);
                            break;

                        case ClassIDType.MeshRenderer:
                            obj = new MeshRenderer(objectReader);
                            break;

                        case ClassIDType.MonoBehaviour:
                            obj = new MonoBehaviour(objectReader);
                            break;

                        case ClassIDType.MonoScript:
                            obj = new MonoScript(objectReader);
                            break;

                        case ClassIDType.MovieTexture:
                            obj = new MovieTexture(objectReader);
                            break;

                        case ClassIDType.PlayerSettings:
                            obj = new PlayerSettings(objectReader);
                            break;

                        case ClassIDType.RectTransform:
                            obj = new RectTransform(objectReader);
                            break;

                        case ClassIDType.Shader:
                            obj = new Shader(objectReader);
                            break;

                        case ClassIDType.SkinnedMeshRenderer:
                            obj = new SkinnedMeshRenderer(objectReader);
                            break;

                        case ClassIDType.Sprite:
                            obj = new Sprite(objectReader);
                            break;

                        case ClassIDType.SpriteAtlas:
                            obj = new SpriteAtlas(objectReader);
                            break;

                        case ClassIDType.TextAsset:
                            obj = new TextAsset(objectReader);
                            break;

                        case ClassIDType.Texture2D:
                            obj = new Texture2D(objectReader);
                            break;

                        case ClassIDType.Transform:
                            obj = new Transform(objectReader);
                            break;

                        case ClassIDType.VideoClip:
                            obj = new VideoClip(objectReader);
                            break;

                        case ClassIDType.ResourceManager:
                            obj = new ResourceManager(objectReader);
                            break;

                        default:
                            obj = new Object(objectReader);
                            break;
                        }
                        assetsFile.AddObject(obj);
                    }
                    catch (Exception e)
                    {
                        /*var sb = new StringBuilder();
                         * sb.AppendLine("Unable to load object")
                         *  .AppendLine($"Assets {assetsFile.fileName}")
                         *  .AppendLine($"Type {objectReader.type}")
                         *  .AppendLine($"PathID {objectInfo.m_PathID}")
                         *  .Append(e);
                         * Logger.Error(sb.ToString());*/
                    }

                    Progress.Report(++i, progressCount);
                }
            }
        }