Beispiel #1
0
 public static Bitmap GetImageFromSprite(Sprite m_Sprite)
 {
     if (m_Sprite.m_SpriteAtlas != null && m_Sprite.m_SpriteAtlas.TryGet(out var objectReader))
     {
         var m_SpriteAtlas = new SpriteAtlas(objectReader);
         if (m_SpriteAtlas.m_RenderDataMap.TryGetValue(m_Sprite.m_RenderDataKey, out var spriteAtlasData) && spriteAtlasData.texture.TryGet(out objectReader))
         {
             return(CutImage(objectReader, spriteAtlasData.textureRect, m_Sprite, spriteAtlasData.settingsRaw));
         }
     }
     else
     {
         if (m_Sprite.texture.TryGet(out objectReader))
         {
             return(CutImage(objectReader, m_Sprite.textureRect, m_Sprite, m_Sprite.settingsRaw));
         }
     }
     return(null);
 }
Beispiel #2
0
        public static Bitmap GetImageFromSprite(AssetPreloadData asset)
        {
            var m_Sprite = new Sprite(asset, true);

            if (assetsfileList.TryGetPD(m_Sprite.m_SpriteAtlas, out var assetPreloadData))
            {
                var m_SpriteAtlas = new SpriteAtlas(assetPreloadData);
                var index         = m_SpriteAtlas.guids.FindIndex(x => x == m_Sprite.first);
                if (index >= 0 && assetsfileList.TryGetPD(m_SpriteAtlas.textures[index], out assetPreloadData))
                {
                    return(CutImage(asset, assetPreloadData, m_SpriteAtlas.textureRects[index], m_Sprite));
                }
            }
            else
            {
                if (assetsfileList.TryGetPD(m_Sprite.texture, out assetPreloadData))
                {
                    return(CutImage(asset, assetPreloadData, m_Sprite.textureRect));
                }
            }

            return(null);
        }
Beispiel #3
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);
                            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.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);
                }
            }
        }