Exemple #1
0
        public static TextureFile ReadTextureFile(AssetTypeValueField baseField)
        {
            TextureFile         texture = new TextureFile();
            AssetTypeValueField tempField;

            texture.m_Name = baseField.Get("m_Name").GetValue().AsString();

            if (!(tempField = baseField.Get("m_ForcedFallbackFormat")).IsDummy())
            {
                texture.m_ForcedFallbackFormat = tempField.GetValue().AsInt();
            }

            if (!(tempField = baseField.Get("m_DownscaleFallback")).IsDummy())
            {
                texture.m_DownscaleFallback = tempField.GetValue().AsBool();
            }

            texture.m_Width = baseField.Get("m_Width").GetValue().AsInt();

            texture.m_Height = baseField.Get("m_Height").GetValue().AsInt();

            if (!(tempField = baseField.Get("m_CompleteImageSize")).IsDummy())
            {
                texture.m_CompleteImageSize = tempField.GetValue().AsInt();
            }

            texture.m_TextureFormat = baseField.Get("m_TextureFormat").GetValue().AsInt();

            if (!(tempField = baseField.Get("m_MipCount")).IsDummy())
            {
                texture.m_MipCount = tempField.GetValue().AsInt();
            }

            if (!(tempField = baseField.Get("m_MipMap")).IsDummy())
            {
                texture.m_MipMap = tempField.GetValue().AsBool();
            }

            texture.m_IsReadable = baseField.Get("m_IsReadable").GetValue().AsBool();

            if (!(tempField = baseField.Get("m_ReadAllowed")).IsDummy())
            {
                texture.m_ReadAllowed = tempField.GetValue().AsBool();
            }

            if (!(tempField = baseField.Get("m_StreamingMipmaps")).IsDummy())
            {
                texture.m_StreamingMipmaps = tempField.GetValue().AsBool();
            }

            if (!(tempField = baseField.Get("m_StreamingMipmapsPriority")).IsDummy())
            {
                texture.m_StreamingMipmapsPriority = tempField.GetValue().AsInt();
            }

            texture.m_ImageCount = baseField.Get("m_ImageCount").GetValue().AsInt();

            texture.m_TextureDimension = baseField.Get("m_TextureDimension").GetValue().AsInt();

            AssetTypeValueField textureSettings = baseField.Get("m_TextureSettings");

            texture.m_TextureSettings.m_FilterMode = textureSettings.Get("m_FilterMode").GetValue().AsInt();

            texture.m_TextureSettings.m_Aniso = textureSettings.Get("m_Aniso").GetValue().AsInt();

            texture.m_TextureSettings.m_MipBias = textureSettings.Get("m_MipBias").GetValue().AsFloat();

            if (!(tempField = textureSettings.Get("m_WrapMode")).IsDummy())
            {
                texture.m_TextureSettings.m_WrapMode = tempField.GetValue().AsInt();
            }

            if (!(tempField = textureSettings.Get("m_WrapU")).IsDummy())
            {
                texture.m_TextureSettings.m_WrapU = tempField.GetValue().AsInt();
            }

            if (!(tempField = textureSettings.Get("m_WrapV")).IsDummy())
            {
                texture.m_TextureSettings.m_WrapV = tempField.GetValue().AsInt();
            }

            if (!(tempField = textureSettings.Get("m_WrapW")).IsDummy())
            {
                texture.m_TextureSettings.m_WrapW = tempField.GetValue().AsInt();
            }

            if (!(tempField = baseField.Get("m_LightmapFormat")).IsDummy())
            {
                texture.m_LightmapFormat = tempField.GetValue().AsInt();
            }

            if (!(tempField = baseField.Get("m_ColorSpace")).IsDummy())
            {
                texture.m_ColorSpace = tempField.GetValue().AsInt();
            }

            AssetTypeValueField imageData = baseField.Get("image data");

            if (imageData.templateField.valueType == EnumValueTypes.ByteArray)
            {
                texture.pictureData = imageData.GetValue().AsByteArray().data;
            }
            else
            {
                int imageDataSize = imageData.GetValue().AsArray().size;
                texture.pictureData = new byte[imageDataSize];
                for (int i = 0; i < imageDataSize; i++)
                {
                    texture.pictureData[i] = (byte)imageData[i].GetValue().AsInt();
                }
            }

            AssetTypeValueField streamData;

            if (!(streamData = baseField.Get("m_StreamData")).IsDummy())
            {
                texture.m_StreamData.offset = streamData.Get("offset").GetValue().AsUInt64();
                texture.m_StreamData.size   = streamData.Get("size").GetValue().AsUInt();
                texture.m_StreamData.path   = streamData.Get("path").GetValue().AsString();
            }

            return(texture);
        }
        public void WriteTo(AssetTypeValueField baseField)
        {
            AssetTypeValueField tempField;

            baseField.Get("m_Name").GetValue().Set(m_Name);

            if (!(tempField = baseField.Get("m_ForcedFallbackFormat")).IsDummy())
            {
                tempField.GetValue().Set(m_ForcedFallbackFormat);
            }

            if (!(tempField = baseField.Get("m_DownscaleFallback")).IsDummy())
            {
                tempField.GetValue().Set(m_DownscaleFallback);
            }

            baseField.Get("m_Width").GetValue().Set(m_Width);

            baseField.Get("m_Height").GetValue().Set(m_Height);

            if (!(tempField = baseField.Get("m_CompleteImageSize")).IsDummy())
            {
                tempField.GetValue().Set(m_CompleteImageSize);
            }

            baseField.Get("m_TextureFormat").GetValue().Set(m_TextureFormat);

            if (!(tempField = baseField.Get("m_MipCount")).IsDummy())
            {
                tempField.GetValue().Set(m_MipCount);
            }

            if (!(tempField = baseField.Get("m_MipMap")).IsDummy())
            {
                tempField.GetValue().Set(m_MipMap);
            }

            baseField.Get("m_IsReadable").GetValue().Set(m_IsReadable);

            if (!(tempField = baseField.Get("m_ReadAllowed")).IsDummy())
            {
                tempField.GetValue().Set(m_ReadAllowed);
            }

            if (!(tempField = baseField.Get("m_StreamingMipmaps")).IsDummy())
            {
                tempField.GetValue().Set(m_StreamingMipmaps);
            }

            if (!(tempField = baseField.Get("m_StreamingMipmapsPriority")).IsDummy())
            {
                tempField.GetValue().Set(m_StreamingMipmapsPriority);
            }

            baseField.Get("m_ImageCount").GetValue().Set(m_ImageCount);

            baseField.Get("m_TextureDimension").GetValue().Set(m_TextureDimension);

            AssetTypeValueField textureSettings = baseField.Get("m_TextureSettings");

            textureSettings.Get("m_FilterMode").GetValue().Set(m_TextureSettings.m_FilterMode);
            textureSettings.Get("m_Aniso").GetValue().Set(m_TextureSettings.m_Aniso);
            textureSettings.Get("m_MipBias").GetValue().Set(m_TextureSettings.m_MipBias);

            if (!(tempField = textureSettings.Get("m_WrapMode")).IsDummy())
            {
                tempField.GetValue().Set(m_TextureSettings.m_WrapMode);
            }

            if (!(tempField = textureSettings.Get("m_WrapU")).IsDummy())
            {
                tempField.GetValue().Set(m_TextureSettings.m_WrapU);
            }

            if (!(tempField = textureSettings.Get("m_WrapV")).IsDummy())
            {
                tempField.GetValue().Set(m_TextureSettings.m_WrapV);
            }

            if (!(tempField = textureSettings.Get("m_WrapW")).IsDummy())
            {
                tempField.GetValue().Set(m_TextureSettings.m_WrapW);
            }

            if (!(tempField = baseField.Get("m_LightmapFormat")).IsDummy())
            {
                tempField.GetValue().Set(m_LightmapFormat);
            }

            if (!(tempField = baseField.Get("m_ColorSpace")).IsDummy())
            {
                tempField.GetValue().Set(m_ColorSpace);
            }

            AssetTypeValueField imageData = baseField.Get("image data");

            if (imageData.templateField.valueType == EnumValueTypes.ByteArray)
            {
                imageData.GetValue().Set(pictureData);
            }
            else
            {
                imageData.GetValue().Set(new AssetTypeArray(pictureData.Length));

                AssetTypeValueField[] children = new AssetTypeValueField[pictureData.Length];
                for (int i = 0; i < pictureData.Length; i++)
                {
                    AssetTypeValueField child = ValueBuilder.DefaultValueFieldFromArrayTemplate(imageData);
                    child.GetValue().Set(pictureData[i]);
                    children[i] = child;
                }

                imageData.SetChildrenList(children);
            }

            AssetTypeValueField streamData;

            if (!(streamData = baseField.Get("m_StreamData")).IsDummy())
            {
                streamData.Get("offset").GetValue().Set(m_StreamData.offset);
                streamData.Get("size").GetValue().Set(m_StreamData.size);
                streamData.Get("path").GetValue().Set(m_StreamData.path);
            }
        }