public void Cleanup()
 {
     ab.Unload(true);
     originTexture = null;
     ab            = null;
     texture       = null;
 }
        public void Init()
        {
            ab            = TestData.LoadBundle("texturetest.bundle");
            originTexture = TestData.LoadFirstAsset <UnityEngine.Texture2D>(ab);
            Assert.IsNotNull(originTexture);

            ByteBuffer result = TextureSaver.Save(originTexture);

            texture = Schema.Texture.GetRootAsTexture(result);
        }
        public void Init()
        {
            Context    context = Context.Unknown;
            ByteBuffer bb      = TestData.LoadResource("suit_metal_dragon_male." + PlatformPath.GetPath(Application.platform).ToLower() + ".texture", out context);

            Assert.IsNotNull(bb);
            Assert.AreNotEqual(context, Context.Unknown);

            TextureUnserializer unserializer = UnserializerFactory.Instance.Create(context) as TextureUnserializer;

            result = unserializer.Parse(bb) as ResourceObjectSingle;
            Assert.IsNotNull(result);
            texture = Schema.Texture.GetRootAsTexture(bb);
        }
Beispiel #4
0
        public ResourceObject Parse(ByteBuffer bb)
        {
            Schema.Texture _texture = Schema.Texture.GetRootAsTexture(bb);

            UnityEngine.Texture2D texture = new Texture2D(_texture.Width, _texture.Height, (UnityEngine.TextureFormat)_texture.Format, _texture.MipmapCount > 1);
            //texture.alphaIsTransparency = _texture.AlphaIsTransparency;
            texture.anisoLevel = _texture.AnisoLevel;
            texture.filterMode = (UnityEngine.FilterMode)_texture.FilterMode;
            texture.mipMapBias = _texture.MipMapBias;
            texture.wrapMode   = (UnityEngine.TextureWrapMode)_texture.WrapMode;

            ArraySegment <byte> arrayRawData = _texture.GetRawDataBytes().GetValueOrDefault();

            byte[] rawData = new byte[arrayRawData.Count];
            Array.Copy(arrayRawData.Array, arrayRawData.Offset, rawData, 0, arrayRawData.Count);
            texture.LoadRawTextureData(rawData);
            texture.Apply(true, true);

            return(new ResourceObjectSingle(texture));
        }
 public void Cleanup()
 {
     result.Dispose();
     result  = null;
     texture = null;
 }