public void EqualSource()
        {
            Assert.AreEqual(texture.Cube, false);
            Assert.AreEqual(texture.Format, (Schema.TextureFormat)originTexture.format);
            Assert.AreEqual(texture.MipmapCount, originTexture.mipmapCount);
            Assert.AreEqual(texture.AlphaIsTransparency, originTexture.alphaIsTransparency);
            Assert.AreEqual(texture.Width, originTexture.width);
            Assert.AreEqual(texture.Height, originTexture.height);
            Assert.AreEqual(texture.Depth, 1);
            Assert.AreEqual(texture.AnisoLevel, originTexture.anisoLevel);
            Assert.AreEqual(texture.FilterMode, (Schema.FilterMode)originTexture.filterMode);
            Assert.AreEqual(texture.MipMapBias, originTexture.mipMapBias);
            Assert.AreEqual(texture.WrapMode, (Schema.TextureWrapMode)originTexture.wrapMode);

            byte[] originRawData = originTexture.GetRawTextureData();

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

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

            Assert.AreEqual(originRawData.Length, texture.RawDataLength);
            Assert.AreEqual(originRawData.Length, arrayRawData.Count);

            for (int i = 0; i < originRawData.Length; i++)
            {
                Assert.AreEqual(originRawData[i], rawData[i]);
            }
        }
Beispiel #2
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));
        }