Add Unity 2017.2 Shader support

Stop decompress Shader
This commit is contained in:
Perfare 2017-11-10 04:24:12 +08:00
parent 120c3e235d
commit 5dd9f31398
4 changed files with 33 additions and 7 deletions

View File

@ -19,7 +19,7 @@ namespace Unity_Studio {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class ShaderResource {
@ -69,6 +69,15 @@ namespace Unity_Studio {
}
}
/// <summary>
/// 查找类似 [{&quot;Level&quot;:0,&quot;Type&quot;:&quot;string&quot;,&quot;Name&quot;:&quot;m_Name&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32769},{&quot;Level&quot;:1,&quot;Type&quot;:&quot;Array&quot;,&quot;Name&quot;:&quot;Array&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:16385},{&quot;Level&quot;:2,&quot;Type&quot;:&quot;int&quot;,&quot;Name&quot;:&quot;size&quot;,&quot;Size&quot;:4,&quot;Flag&quot;:1},{&quot;Level&quot;:2,&quot;Type&quot;:&quot;char&quot;,&quot;Name&quot;:&quot;data&quot;,&quot;Size&quot;:1,&quot;Flag&quot;:1},{&quot;Level&quot;:0,&quot;Type&quot;:&quot;SerializedShader&quot;,&quot;Name&quot;:&quot;m_ParsedForm&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32768},{&quot;Level&quot;:1,&quot;Type&quot;:&quot;SerializedProperties&quot;,&quot;Name&quot;:&quot;m_PropInfo&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32768},{&quot;Level&quot;:2,&quot;Type&quot;:&quot;vector&quot;,&quot;Name&quot;:&quot;m_Props&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32768},{&quot;Level&quot;:3,&quot;Type&quot;:&quot;Arr... 的本地化字符串。
/// </summary>
internal static string Shader20172 {
get {
return ResourceManager.GetString("Shader20172", resourceCulture);
}
}
/// <summary>
/// 查找类似 [{&quot;Level&quot;:0,&quot;Type&quot;:&quot;string&quot;,&quot;Name&quot;:&quot;m_Name&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32769},{&quot;Level&quot;:1,&quot;Type&quot;:&quot;Array&quot;,&quot;Name&quot;:&quot;Array&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:16385},{&quot;Level&quot;:2,&quot;Type&quot;:&quot;int&quot;,&quot;Name&quot;:&quot;size&quot;,&quot;Size&quot;:4,&quot;Flag&quot;:1},{&quot;Level&quot;:2,&quot;Type&quot;:&quot;char&quot;,&quot;Name&quot;:&quot;data&quot;,&quot;Size&quot;:1,&quot;Flag&quot;:1},{&quot;Level&quot;:0,&quot;Type&quot;:&quot;SerializedShader&quot;,&quot;Name&quot;:&quot;m_ParsedForm&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32768},{&quot;Level&quot;:1,&quot;Type&quot;:&quot;SerializedProperties&quot;,&quot;Name&quot;:&quot;m_PropInfo&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32768},{&quot;Level&quot;:2,&quot;Type&quot;:&quot;vector&quot;,&quot;Name&quot;:&quot;m_Props&quot;,&quot;Size&quot;:-1,&quot;Flag&quot;:32768},{&quot;Level&quot;:3,&quot;Type&quot;:&quot;Arr... 的本地化字符串。
/// </summary>

File diff suppressed because one or more lines are too long

View File

@ -33,10 +33,24 @@ namespace Unity_Studio
{
if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 5 || sourceFile.version[0] > 5)//5.5.0 and up
{
a_Stream.Position = preloadData.Offset;
var str = (string)ShaderResource.ResourceManager.GetObject($"Shader{sourceFile.version[0]}{sourceFile.version[1]}");
var members = new JavaScriptSerializer().Deserialize<List<ClassMember>>(str);
m_Script = ReadSerializedShader(members, a_Stream);
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
{
@ -66,7 +80,7 @@ namespace Unity_Studio
}
}
private static byte[] ReadSerializedShader(List<ClassMember> members, EndianBinaryReader a_Stream)
/*private static byte[] ReadSerializedShader(List<ClassMember> members, EndianBinaryReader a_Stream)
{
var offsets = new List<uint>();
var compressedLengths = new List<uint>();
@ -187,6 +201,6 @@ namespace Unity_Studio
a_Stream.AlignStream(4);
}
return null;
}
}*/
}
}

View File

@ -53,7 +53,7 @@ namespace Unity_Studio
return null;
}
private static void ReadClassStruct(StringBuilder sb, List<ClassMember> members, EndianBinaryReader a_Stream)
public static void ReadClassStruct(StringBuilder sb, List<ClassMember> members, EndianBinaryReader a_Stream)
{
for (int i = 0; i < members.Count; i++)
{