コード例 #1
0
        private static string ConvertSerializedShader(SerializedShader m_ParsedForm, ShaderCompilerPlatform[] platforms, ShaderProgram[] shaderPrograms)
        {
            var sb = new StringBuilder();

            sb.Append($"Shader \"{m_ParsedForm.m_Name}\" {{\n");

            sb.Append(ConvertSerializedProperties(m_ParsedForm.m_PropInfo));

            foreach (var m_SubShader in m_ParsedForm.m_SubShaders)
            {
                sb.Append(ConvertSerializedSubShader(m_SubShader, platforms, shaderPrograms));
            }

            if (!string.IsNullOrEmpty(m_ParsedForm.m_FallbackName))
            {
                sb.Append($"Fallback \"{m_ParsedForm.m_FallbackName}\"\n");
            }

            if (!string.IsNullOrEmpty(m_ParsedForm.m_CustomEditorName))
            {
                sb.Append($"CustomEditor \"{m_ParsedForm.m_CustomEditorName}\"\n");
            }

            sb.Append("}");
            return(sb.ToString());
        }
コード例 #2
0
 public Shader(ObjectReader reader) : base(reader)
 {
     if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5 and up
     {
         m_ParsedForm = new SerializedShader(reader);
         platforms    = reader.ReadUInt32Array().Select(x => (ShaderCompilerPlatform)x).ToArray();
         if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
         {
             offsets             = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
             compressedLengths   = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
             decompressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
         }
         else
         {
             offsets             = reader.ReadUInt32Array();
             compressedLengths   = reader.ReadUInt32Array();
             decompressedLengths = reader.ReadUInt32Array();
         }
         compressedBlob = reader.ReadBytes(reader.ReadInt32());
     }
     else
     {
         m_Script = reader.ReadBytes(reader.ReadInt32());
         reader.AlignStream();
         var m_PathName = reader.ReadAlignedString();
         if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4
         {
             decompressedSize = reader.ReadUInt32();
             m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32());
         }
     }
 }
コード例 #3
0
ファイル: Shader.cs プロジェクト: zbx911/AssetStudio
        public Shader(ObjectReader reader) : base(reader)
        {
            if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5 and up
            {
                m_ParsedForm = new SerializedShader(reader);
                platforms    = reader.ReadUInt32Array().Select(x => (ShaderCompilerPlatform)x).ToArray();
                if (version[0] > 2019 || (version[0] == 2019 && version[1] >= 3)) //2019.3 and up
                {
                    offsets             = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
                    compressedLengths   = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
                    decompressedLengths = reader.ReadUInt32ArrayArray().Select(x => x[0]).ToArray();
                }
                else
                {
                    offsets             = reader.ReadUInt32Array();
                    compressedLengths   = reader.ReadUInt32Array();
                    decompressedLengths = reader.ReadUInt32Array();
                }
                compressedBlob = reader.ReadUInt8Array();
                reader.AlignStream();

                var m_DependenciesCount = reader.ReadInt32();
                for (int i = 0; i < m_DependenciesCount; i++)
                {
                    new PPtr <Shader>(reader);
                }

                if (version[0] >= 2018)
                {
                    var m_NonModifiableTexturesCount = reader.ReadInt32();
                    for (int i = 0; i < m_NonModifiableTexturesCount; i++)
                    {
                        var first = reader.ReadAlignedString();
                        new PPtr <Texture>(reader);
                    }
                }

                var m_ShaderIsBaked = reader.ReadBoolean();
                reader.AlignStream();
            }
            else
            {
                m_Script = reader.ReadUInt8Array();
                reader.AlignStream();
                var m_PathName = reader.ReadAlignedString();
                if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4
                {
                    decompressedSize = reader.ReadUInt32();
                    m_SubProgramBlob = reader.ReadUInt8Array();
                }
            }
        }
コード例 #4
0
ファイル: Shader.cs プロジェクト: zhukunqian/AssetStudio
        public Shader(ObjectReader reader) : base(reader)
        {
            if (version[0] == 5 && version[1] >= 5 || version[0] > 5) //5.5 and up
            {
                m_ParsedForm = new SerializedShader(reader);
                int numPlatforms = reader.ReadInt32();
                platforms = new List <uint>(numPlatforms);
                for (int i = 0; i < numPlatforms; i++)
                {
                    platforms.Add(reader.ReadUInt32());
                }

                int numOffsets = reader.ReadInt32();
                offsets = new List <uint>(numOffsets);
                for (int i = 0; i < numOffsets; i++)
                {
                    offsets.Add(reader.ReadUInt32());
                }

                int numCompressedLengths = reader.ReadInt32();
                compressedLengths = new List <uint>(numCompressedLengths);
                for (int i = 0; i < numCompressedLengths; i++)
                {
                    compressedLengths.Add(reader.ReadUInt32());
                }

                int numDecompressedLengths = reader.ReadInt32();
                decompressedLengths = new List <uint>(numDecompressedLengths);
                for (int i = 0; i < numDecompressedLengths; i++)
                {
                    decompressedLengths.Add(reader.ReadUInt32());
                }

                compressedBlob = reader.ReadBytes(reader.ReadInt32());
            }
            else
            {
                m_Script = reader.ReadBytes(reader.ReadInt32());
                reader.AlignStream(4);
                var m_PathName = reader.ReadAlignedString();
                if (version[0] == 5 && version[1] >= 3) //5.3 - 5.4
                {
                    decompressedSize = reader.ReadUInt32();
                    m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32());
                }
            }
        }