public MonoBehaviour(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var a_Stream   = preloadData.sourceFile.a_Stream;

            a_Stream.Position = preloadData.Offset;

            var m_GameObject = sourceFile.ReadPPtr();
            var m_Enabled    = a_Stream.ReadByte();

            a_Stream.AlignStream(4);
            var m_Script = sourceFile.ReadPPtr();
            var m_Name   = a_Stream.ReadAlignedString(a_Stream.ReadInt32());

            if (readSwitch)
            {
                if ((serializedText = preloadData.ViewStruct()) == null)
                {
                    var str = "PPtr<GameObject> m_GameObject\n";
                    str           += "\tint m_FileID = " + m_GameObject.m_FileID + "\n";
                    str           += "\tint64 m_PathID = " + m_GameObject.m_PathID + "\n";
                    str           += "UInt8 m_Enabled = " + m_Enabled + "\n";
                    str           += "PPtr<MonoScript> m_Script\n";
                    str           += "\tint m_FileID = " + m_Script.m_FileID + "\n";
                    str           += "\tint64 m_PathID = " + m_Script.m_PathID + "\n";
                    str           += "string m_Name = \"" + m_Name + "\"\n";
                    serializedText = str;
                }
            }
            else
            {
                preloadData.extension = ".snaa";
                preloadData.Text      = m_Name;
            }
        }
        public MonoBehaviour(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var a_Stream   = preloadData.sourceFile.a_Stream;

            a_Stream.Position = preloadData.Offset;

            var m_GameObject = sourceFile.ReadPPtr();
            var m_Enabled    = a_Stream.ReadByte();

            a_Stream.AlignStream(4);
            var m_Script = sourceFile.ReadPPtr();
            var m_Name   = a_Stream.ReadAlignedString(a_Stream.ReadInt32());

            if (readSwitch)
            {
                preloadData.extension = ".txt";
                if ((serializedText = preloadData.ViewStruct()) == null)
                {
                    var str = "PPtr<GameObject> m_GameObject\r\n";
                    str           += "\tint m_FileID = " + m_GameObject.m_FileID + "\r\n";
                    str           += "\tint64 m_PathID = " + m_GameObject.m_PathID + "\r\n";
                    str           += "UInt8 m_Enabled = " + m_Enabled + "\r\n";
                    str           += "PPtr<MonoScript> m_Script\r\n";
                    str           += "\tint m_FileID = " + m_Script.m_FileID + "\r\n";
                    str           += "\tint64 m_PathID = " + m_Script.m_PathID + "\r\n";
                    str           += "string m_Name = \"" + m_Name + "\"\r\n";
                    serializedText = str;
                }
            }
            else
            {
                if (m_Name != "")
                {
                    preloadData.Text = m_Name;
                }
                else
                {
                    preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID;
                }
                preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
            }
        }
示例#3
0
        public TextAsset(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var a_Stream   = preloadData.sourceFile.a_Stream;

            a_Stream.Position = preloadData.Offset;

            if (sourceFile.platform == -2)
            {
                uint m_ObjectHideFlags    = a_Stream.ReadUInt32();
                PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
                PPtr m_PrefabInternal     = sourceFile.ReadPPtr();
            }

            m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());

            if (readSwitch)
            {
                if (false)  //Using preview structure instead of raw content
                {
                    var str1 = preloadData.ViewStruct();
                    if (str1 == null)
                    {
                        m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
                    }
                    else
                    {
                        m_Script = Encoding.UTF8.GetBytes(str1);
                    }
                }
                else
                {
                    m_Script = a_Stream.ReadBytes(a_Stream.ReadInt32());
                }
            }
            else
            {
                preloadData.extension = ".txt";
                preloadData.Text      = m_Name;
            }
        }
示例#4
0
        public Shader(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var a_Stream   = preloadData.sourceFile.a_Stream;

            a_Stream.Position = preloadData.Offset;

            if (sourceFile.platform == -2)
            {
                uint m_ObjectHideFlags    = a_Stream.ReadUInt32();
                PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
                PPtr m_PrefabInternal     = sourceFile.ReadPPtr();
            }

            m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());

            if (readSwitch)
            {
                if (true)
                {
                    //Assume as unity 5.6 or greater.
                    var str1 = preloadData.ViewStruct();
                    if (str1 == null)
                    {
                        m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
                    }
                    else
                    {
                        m_Script = Encoding.UTF8.GetBytes(str1);
                    }
                    return;
                }

                /**
                 * SHORTCUT:
                 * System.Resources.MissingManifestResourceException: Could not find
                 * any resources appropriate for the specified culture or the neutral
                 * culture.  Make sure "Unity_Studio.ShaderResource.resources" was
                 * correctly embedded or linked into assembly "adebug" at compile
                 * time, or that all the satellite assemblies required are loadable
                 * and fully signed.
                 */
                if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 5 || sourceFile.version[0] > 5)//5.5.0 and up
                {
                    var str = (string)ShaderResource.ResourceManager.GetObject($"Shader{sourceFile.version[0]}{sourceFile.version[1]}");
                    if (str == null)
                    {
                        str = preloadData.ViewStruct();
                        if (str == null)
                        {
                            m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
                        }
                        else
                        {
                            m_Script = Encoding.UTF8.GetBytes(str);
                        }
                    }
                    else
                    {
                        a_Stream.Position = preloadData.Offset;
                        var sb      = new StringBuilder();
                        var members = new JavaScriptSerializer().Deserialize <List <ClassMember> >(str);
                        ClassStructHelper.ReadClassStruct(sb, members, a_Stream);
                        m_Script = Encoding.UTF8.GetBytes(sb.ToString());
                        //m_Script = ReadSerializedShader(members, a_Stream);
                    }
                }
                else
                {
                    m_Script = a_Stream.ReadBytes(a_Stream.ReadInt32());
                    if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) //5.3 - 5.4
                    {
                        a_Stream.AlignStream(4);
                        a_Stream.ReadAlignedString(a_Stream.ReadInt32());//m_PathName
                        var decompressedSize  = a_Stream.ReadUInt32();
                        var m_SubProgramBlob  = a_Stream.ReadBytes(a_Stream.ReadInt32());
                        var decompressedBytes = new byte[decompressedSize];
                        using (var mstream = new MemoryStream(m_SubProgramBlob))
                        {
                            var decoder = new Lz4DecoderStream(mstream);
                            decoder.Read(decompressedBytes, 0, (int)decompressedSize);
                            decoder.Dispose();
                        }
                        m_Script = m_Script.Concat(decompressedBytes.ToArray()).ToArray();
                    }
                }
            }
            else
            {
                preloadData.extension = ".txt";
                preloadData.Text      = m_Name;
            }
        }
示例#5
0
        public Shader(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var a_Stream   = preloadData.sourceFile.a_Stream;

            a_Stream.Position = preloadData.Offset;

            if (sourceFile.platform == -2)
            {
                uint m_ObjectHideFlags    = a_Stream.ReadUInt32();
                PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
                PPtr m_PrefabInternal     = sourceFile.ReadPPtr();
            }

            m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());

            if (readSwitch)
            {
                if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 5 || sourceFile.version[0] > 5)//5.5.0 and up
                {
                    var str = (string)ShaderResource.ResourceManager.GetObject($"Shader{sourceFile.version[0]}{sourceFile.version[1]}");
                    if (str == null)
                    {
                        str = preloadData.ViewStruct();
                        if (str == null)
                        {
                            m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
                        }
                        else
                        {
                            m_Script = Encoding.UTF8.GetBytes(str);
                        }
                    }
                    else
                    {
                        a_Stream.Position = preloadData.Offset;
                        var sb      = new StringBuilder();
                        var members = new JavaScriptSerializer().Deserialize <List <ClassMember> >(str);
                        ClassStructHelper.ReadClassStruct(sb, members, a_Stream);
                        m_Script = Encoding.UTF8.GetBytes(sb.ToString());
                        //m_Script = ReadSerializedShader(members, a_Stream);
                    }
                }
                else
                {
                    m_Script = a_Stream.ReadBytes(a_Stream.ReadInt32());
                    if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) //5.3 - 5.4
                    {
                        a_Stream.AlignStream(4);
                        a_Stream.ReadAlignedString(a_Stream.ReadInt32());//m_PathName
                        var decompressedSize  = a_Stream.ReadUInt32();
                        var m_SubProgramBlob  = a_Stream.ReadBytes(a_Stream.ReadInt32());
                        var decompressedBytes = new byte[decompressedSize];
                        using (var mstream = new MemoryStream(m_SubProgramBlob))
                        {
                            var decoder = new Lz4DecoderStream(mstream);
                            decoder.Read(decompressedBytes, 0, (int)decompressedSize);
                            decoder.Dispose();
                        }
                        m_Script = m_Script.Concat(decompressedBytes.ToArray()).ToArray();
                    }
                }
            }
            else
            {
                preloadData.extension = ".txt";
                preloadData.Text      = m_Name;
            }
        }
示例#6
0
        public Shader(AssetPreloadData preloadData, bool readSwitch)
        {
            var sourceFile = preloadData.sourceFile;
            var a_Stream   = preloadData.sourceFile.a_Stream;

            a_Stream.Position     = preloadData.Offset;
            preloadData.extension = ".txt";

            if (sourceFile.platform == -2)
            {
                uint m_ObjectHideFlags    = a_Stream.ReadUInt32();
                PPtr m_PrefabParentObject = sourceFile.ReadPPtr();
                PPtr m_PrefabInternal     = sourceFile.ReadPPtr();
            }

            m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
            if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)
            {
                if (readSwitch)
                {
                    string str;
                    if ((str = preloadData.ViewStruct()) != null)
                    {
                        m_Script = Encoding.UTF8.GetBytes(preloadData.ViewStruct());
                    }
                    else
                    {
                        m_Script = Encoding.UTF8.GetBytes("Serialized Shader can't be read");
                    }
                }
                else
                {
                    if (m_Name != "")
                    {
                        preloadData.Text = m_Name;
                    }
                    else
                    {
                        preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID;
                    }
                    preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
                }
            }
            else
            {
                int m_Script_size = a_Stream.ReadInt32();

                if (readSwitch) //asset is read for preview or export
                {
                    m_Script = new byte[m_Script_size];
                    a_Stream.Read(m_Script, 0, m_Script_size);

                    if (m_Script[0] == 93)
                    {
                        m_Script = SevenZip.Compression.LZMA.SevenZipHelper.Decompress(m_Script);
                    }
                    if (m_Script[0] == 60 || (m_Script[0] == 239 && m_Script[1] == 187 && m_Script[2] == 191 && m_Script[3] == 60))
                    {
                        preloadData.extension = ".xml";
                    }
                }
                else
                {
                    byte lzmaTest = a_Stream.ReadByte();

                    a_Stream.Position += m_Script_size - 1;

                    if (m_Name != "")
                    {
                        preloadData.Text = m_Name;
                    }
                    else
                    {
                        preloadData.Text = preloadData.TypeString + " #" + preloadData.uniqueID;
                    }
                    preloadData.SubItems.AddRange(new[] { preloadData.TypeString, preloadData.Size.ToString() });
                }
                a_Stream.AlignStream(4);
                m_PathName = a_Stream.ReadAlignedString(a_Stream.ReadInt32());
            }
        }