public static bool ExportRawFile(AssetPreloadData asset, string exportPath, string fileExtension = ".dat") { var exportFullName = Path.Combine(exportPath, string.Concat(asset.Text, fileExtension)); switch (asset.Type) { case ClassIDType.MonoBehaviour: exportFullName = GetExportMonoBehaviourPath(asset, exportPath, fileExtension); break; case ClassIDType.MonoScript: exportFullName = GetExportMonoScriptPath(asset, exportPath, fileExtension); break; } if (ExportFileExists(exportFullName)) { return(false); } var bytes = asset.InitReader().ReadBytes((int)asset.Size); File.WriteAllBytes(exportFullName, bytes); return(true); }
public MonoBehaviour(AssetPreloadData preloadData, bool readSwitch) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); var m_GameObject = sourceFile.ReadPPtr(); var m_Enabled = reader.ReadByte(); reader.AlignStream(4); var m_Script = sourceFile.ReadPPtr(); var m_Name = reader.ReadAlignedString(); if (readSwitch) { if ((serializedText = preloadData.GetClassString()) == 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 { preloadData.extension = ".txt"; preloadData.Text = m_Name; } }
public MonoScript(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); var version = sourceFile.version; m_Name = reader.ReadAlignedString(); if (version[0] > 3 || (version[0] == 3 && version[1] >= 4)) { var m_ExecutionOrder = reader.ReadAlignedString(); } if (version[0] < 5) { var m_PropertiesHash = reader.ReadUInt32(); } else { var m_PropertiesHash = reader.ReadBytes(16); } if (version[0] < 3) { var m_PathName = reader.ReadAlignedString(); } m_ClassName = reader.ReadAlignedString(); if (version[0] >= 3) { m_Namespace = reader.ReadAlignedString(); } m_AssemblyName = reader.ReadAlignedString(); if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) { var m_IsEditorScript = reader.ReadBoolean(); } }
public AnimatorController(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var version = preloadData.sourceFile.version; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_Name = reader.ReadAlignedString(); var m_ControllerSize = reader.ReadUInt32(); var m_Controller = new ControllerConstant(reader, version); int tosSize = reader.ReadInt32(); var m_TOS = new List <KeyValuePair <uint, string> >(tosSize); for (int i = 0; i < tosSize; i++) { m_TOS.Add(new KeyValuePair <uint, string>(reader.ReadUInt32(), reader.ReadAlignedString())); } int numClips = reader.ReadInt32(); m_AnimationClips = new PPtr[numClips]; for (int i = 0; i < numClips; i++) { m_AnimationClips[i] = sourceFile.ReadPPtr(); } }
public MeshFilter(AssetPreloadData preloadData, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_GameObject = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); m_Mesh = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); }
public MeshFilter(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_GameObject = sourceFile.ReadPPtr(); m_Mesh = sourceFile.ReadPPtr(); }
public Shader(AssetPreloadData preloadData, bool readSwitch) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_Name = reader.ReadAlignedString(); 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 { reader.Position = preloadData.Offset; var sb = new StringBuilder(); var members = new JavaScriptSerializer().Deserialize <List <ClassMember> >(str); ClassStructHelper.ReadClassStruct(sb, members, reader); m_Script = Encoding.UTF8.GetBytes(sb.ToString()); //m_Script = ReadSerializedShader(members, a_Stream); } } else { m_Script = reader.ReadBytes(reader.ReadInt32()); if (sourceFile.version[0] == 5 && sourceFile.version[1] >= 3) //5.3 - 5.4 { reader.AlignStream(4); reader.ReadAlignedString();//m_PathName var decompressedSize = reader.ReadUInt32(); var m_SubProgramBlob = reader.ReadBytes(reader.ReadInt32()); var decompressedBytes = new byte[decompressedSize]; using (var decoder = new Lz4DecoderStream(new MemoryStream(m_SubProgramBlob))) { decoder.Read(decompressedBytes, 0, (int)decompressedSize); } m_Script = m_Script.Concat(decompressedBytes.ToArray()).ToArray(); } } } else { preloadData.extension = ".txt"; preloadData.Text = m_Name; } }
public MonoBehaviour(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_GameObject = sourceFile.ReadPPtr(); m_Enabled = reader.ReadByte(); reader.AlignStream(4); m_Script = sourceFile.ReadPPtr(); m_Name = reader.ReadAlignedString(); }
public static string ViewStruct(this AssetPreloadData asset) { var reader = asset.InitReader(); if (asset.sourceFile.ClassStructures.TryGetValue(asset.Type1, out var classStructure)) { var sb = new StringBuilder(); ReadClassStruct(sb, classStructure.members, reader); return(sb.ToString()); } return(null); }
public static bool ExportRawFile(AssetPreloadData asset, string exportPath) { var exportFullName = exportPath + asset.Text + ".dat"; if (ExportFileExists(exportFullName)) { return(false); } var bytes = asset.InitReader().ReadBytes((int)asset.Size); File.WriteAllBytes(exportFullName, bytes); return(true); }
public Animator(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_GameObject = sourceFile.ReadPPtr(); var m_Enabled = reader.ReadByte(); reader.AlignStream(4); m_Avatar = sourceFile.ReadPPtr(); m_Controller = sourceFile.ReadPPtr(); }
public Animator(AssetPreloadData preloadData, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_GameObject = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); var m_Enabled = reader.ReadByte(); reader.AlignStream(4); m_Avatar = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); m_Controller = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); }
protected Object(AssetPreloadData preloadData) { this.preloadData = preloadData; sourceFile = preloadData.sourceFile; reader = preloadData.InitReader(); version = sourceFile.version; buildType = sourceFile.buildType; platform = sourceFile.m_TargetPlatform; if (platform == BuildTarget.NoTarget) { var m_ObjectHideFlags = reader.ReadUInt32(); } }
public SpriteAtlas(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); var m_Name = reader.ReadAlignedString(); //vector m_PackedSprites var size = reader.ReadInt32(); for (int i = 0; i < size; i++) { //PPtr<Sprite> data sourceFile.ReadPPtr(); } //vector m_PackedSpriteNamesToIndex size = reader.ReadInt32(); for (int i = 0; i < size; i++) { var data = reader.ReadAlignedString(); } //map m_RenderDataMap size = reader.ReadInt32(); for (int i = 0; i < size; i++) { //pair first guids.Add(new Guid(reader.ReadBytes(16))); var second = reader.ReadInt64(); //SpriteAtlasData second // PPtr<Texture2D> texture textures.Add(sourceFile.ReadPPtr()); // PPtr<Texture2D> alphaTexture var alphaTexture = sourceFile.ReadPPtr(); // Rectf textureRect textureRects.Add(new RectangleF(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle())); // Vector2f textureRectOffset reader.Position += 8; if (sourceFile.version[0] > 2017 || (sourceFile.version[0] == 2017 && sourceFile.version[1] >= 2))//2017.2 and up { // Vector2f atlasRectOffset reader.Position += 8; } // Vector4f uvTransform // float downscaleMultiplier // unsigned int settingsRaw reader.Position += 24; } //string m_Tag //bool m_IsVariant }
public MeshFilter(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); if (sourceFile.platform == -2) { uint m_ObjectHideFlags = reader.ReadUInt32(); PPtr m_PrefabParentObject = sourceFile.ReadPPtr(); PPtr m_PrefabInternal = sourceFile.ReadPPtr(); } m_GameObject = sourceFile.ReadPPtr(); m_Mesh = sourceFile.ReadPPtr(); }
public MeshRenderer(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); if (sourceFile.platform == -2) { uint m_ObjectHideFlags = reader.ReadUInt32(); PPtr m_PrefabParentObject = sourceFile.ReadPPtr(); PPtr m_PrefabInternal = sourceFile.ReadPPtr(); } m_GameObject = sourceFile.ReadPPtr(); if (sourceFile.version[0] < 5) { m_Enabled = reader.ReadBoolean(); m_CastShadows = reader.ReadByte(); m_ReceiveShadows = reader.ReadBoolean(); m_LightmapIndex = reader.ReadByte(); } else { m_Enabled = reader.ReadBoolean(); reader.AlignStream(4); m_CastShadows = reader.ReadByte(); m_ReceiveShadows = reader.ReadBoolean(); reader.AlignStream(4); m_LightmapIndex = reader.ReadUInt16(); m_LightmapIndexDynamic = reader.ReadUInt16(); } if (sourceFile.version[0] >= 3) { reader.Position += 16; } //Vector4f m_LightmapTilingOffset if (sourceFile.version[0] >= 5) { reader.Position += 16; } //Vector4f m_LightmapTilingOffsetDynamic m_Materials = new PPtr[reader.ReadInt32()]; for (int m = 0; m < m_Materials.Length; m++) { m_Materials[m] = sourceFile.ReadPPtr(); } }
public string uniqueID = "0";//this way file and folder TreeNodes will be treated as FBX scene public GameObject(AssetPreloadData preloadData) { if (preloadData != null) { asset = preloadData; var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); uniqueID = preloadData.uniqueID; if (sourceFile.platform == -2) { uint m_ObjectHideFlags = reader.ReadUInt32(); PPtr m_PrefabParentObject = sourceFile.ReadPPtr(); PPtr m_PrefabInternal = sourceFile.ReadPPtr(); } int m_Component_size = reader.ReadInt32(); for (int j = 0; j < m_Component_size; j++) { if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up { m_Components.Add(sourceFile.ReadPPtr()); } else { int first = reader.ReadInt32(); m_Components.Add(sourceFile.ReadPPtr()); } } m_Layer = reader.ReadInt32(); m_Name = reader.ReadAlignedString(); if (m_Name == "") { m_Name = "GameObject #" + uniqueID; } m_Tag = reader.ReadUInt16(); m_IsActive = reader.ReadBoolean(); Text = m_Name; preloadData.Text = m_Name; //name should be unique Name = uniqueID; } }
public PPtr m_Father = new PPtr();//can be transform or type 224 (as seen in Minions) public Transform(AssetPreloadData preloadData, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_GameObject = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); m_LocalRotation = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }; m_LocalPosition = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }; m_LocalScale = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }; int m_ChildrenCount = reader.ReadInt32(); for (int j = 0; j < m_ChildrenCount; j++) { m_Children.Add(sourceFile.ReadPPtr(sharedFileIndex, assetsfileList)); } m_Father = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); }
public PPtr m_Father = new PPtr();//can be transform or type 224 (as seen in Minions) public Transform(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_GameObject = sourceFile.ReadPPtr(); m_LocalRotation = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }; m_LocalPosition = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }; m_LocalScale = new[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() }; int m_ChildrenCount = reader.ReadInt32(); for (int j = 0; j < m_ChildrenCount; j++) { m_Children.Add(sourceFile.ReadPPtr()); } m_Father = sourceFile.ReadPPtr(); }
public TextAsset(AssetPreloadData preloadData, bool readSwitch) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_Name = reader.ReadAlignedString(); if (readSwitch) { m_Script = reader.ReadBytes(reader.ReadInt32()); } else { preloadData.extension = ".txt"; preloadData.Text = m_Name; } }
public MeshRenderer(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var version = sourceFile.version; var reader = preloadData.InitReader(); m_GameObject = sourceFile.ReadPPtr(); if (version[0] < 5) { var m_Enabled = reader.ReadBoolean(); var m_CastShadows = reader.ReadByte(); var m_ReceiveShadows = reader.ReadBoolean(); var m_LightmapIndex = reader.ReadByte(); } else { var m_Enabled = reader.ReadBoolean(); reader.AlignStream(4); var m_CastShadows = reader.ReadByte(); var m_ReceiveShadows = reader.ReadBoolean(); reader.AlignStream(4); if (version[0] >= 2018)//2018 and up { var m_RenderingLayerMask = reader.ReadUInt32(); } var m_LightmapIndex = reader.ReadUInt16(); var m_LightmapIndexDynamic = reader.ReadUInt16(); } if (version[0] >= 3) { reader.Position += 16;//Vector4f m_LightmapTilingOffset } if (version[0] >= 5) { reader.Position += 16;//Vector4f m_LightmapTilingOffsetDynamic } m_Materials = new PPtr[reader.ReadInt32()]; for (int m = 0; m < m_Materials.Length; m++) { m_Materials[m] = sourceFile.ReadPPtr(); } }
public Animation(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_GameObject = sourceFile.ReadPPtr(); var m_Enabled = reader.ReadByte(); reader.AlignStream(4); var m_Animation = sourceFile.ReadPPtr(); int numAnimations = reader.ReadInt32(); m_Animations = new List <PPtr>(numAnimations); for (int i = 0; i < numAnimations; i++) { m_Animations.Add(sourceFile.ReadPPtr()); } }
public AnimatorOverrideController(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_Name = reader.ReadAlignedString(); m_Controller = sourceFile.ReadPPtr(); int numOverrides = reader.ReadInt32(); m_Clips = new PPtr[numOverrides][]; for (int i = 0; i < numOverrides; i++) { m_Clips[i] = new PPtr[2]; m_Clips[i][0] = sourceFile.ReadPPtr(); m_Clips[i][1] = sourceFile.ReadPPtr(); } }
public Animation(AssetPreloadData preloadData, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_GameObject = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); var m_Enabled = reader.ReadByte(); reader.AlignStream(4); var m_Animation = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); int numAnimations = reader.ReadInt32(); m_Animations = new List <PPtr>(numAnimations); for (int i = 0; i < numAnimations; i++) { m_Animations.Add(sourceFile.ReadPPtr(sharedFileIndex, assetsfileList)); } }
public AnimatorOverrideController(AssetPreloadData preloadData, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_Name = reader.ReadAlignedString(); m_Controller = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); int numOverrides = reader.ReadInt32(); m_Clips = new PPtr[numOverrides][]; for (int i = 0; i < numOverrides; i++) { m_Clips[i] = new PPtr[2]; m_Clips[i][0] = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); m_Clips[i][1] = sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); } }
public Avatar(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var version = sourceFile.version; var reader = preloadData.InitReader(); reader.Position = preloadData.Offset; m_Name = reader.ReadAlignedString(); m_AvatarSize = reader.ReadUInt32(); m_Avatar = new AvatarConstant(reader, version); int numTOS = reader.ReadInt32(); m_TOS = new List <KeyValuePair <uint, string> >(numTOS); for (int i = 0; i < numTOS; i++) { m_TOS.Add(new KeyValuePair <uint, string>(reader.ReadUInt32(), reader.ReadAlignedString())); } }
public GameObject(AssetPreloadData preloadData, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { if (preloadData != null) { asset = preloadData; var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); uniqueID = preloadData.uniqueID; int m_Component_size = reader.ReadInt32(); m_Components = new List <PPtr>(m_Component_size); for (int j = 0; j < m_Component_size; j++) { if ((sourceFile.version[0] == 5 && sourceFile.version[1] >= 5) || sourceFile.version[0] > 5)//5.5.0 and up { m_Components.Add(sourceFile.ReadPPtr(sharedFileIndex, assetsfileList)); } else { int first = reader.ReadInt32(); m_Components.Add(sourceFile.ReadPPtr(sharedFileIndex, assetsfileList)); } } m_Layer = reader.ReadInt32(); m_Name = reader.ReadAlignedString(); if (m_Name == "") { m_Name = "GameObject #" + uniqueID; } m_Tag = reader.ReadUInt16(); m_IsActive = reader.ReadBoolean(); Text = m_Name; preloadData.FullName = m_Name; //name should be unique Name = uniqueID; } }
public BuildSettings(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); int levels = reader.ReadInt32(); for (int l = 0; l < levels; l++) { string level = reader.ReadAlignedString(); } if (sourceFile.version[0] == 5) { int preloadedPlugins = reader.ReadInt32(); for (int l = 0; l < preloadedPlugins; l++) { string preloadedPlugin = reader.ReadAlignedString(); } } reader.Position += 4; //bool flags if (sourceFile.fileGen >= 8) { reader.Position += 4; } //bool flags if (sourceFile.fileGen >= 9) { reader.Position += 4; } //bool flags if (sourceFile.version[0] == 5 || (sourceFile.version[0] == 4 && (sourceFile.version[1] >= 3 || (sourceFile.version[1] == 2 && sourceFile.buildType[0] != "a")))) { reader.Position += 4; } //bool flags m_Version = reader.ReadAlignedString(); }
public MovieTexture(AssetPreloadData preloadData, bool readSwitch) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_Name = reader.ReadAlignedString(); if (readSwitch) { var m_Loop = reader.ReadBoolean(); reader.AlignStream(4); //PPtr<AudioClip> sourceFile.ReadPPtr(); var size = reader.ReadInt32(); m_MovieData = reader.ReadBytes(size); var m_ColorSpace = reader.ReadInt32(); } else { preloadData.extension = ".ogv"; preloadData.Text = m_Name; } }
public MovieTexture(AssetPreloadData preloadData, bool readSwitch, Dictionary <string, int> sharedFileIndex, List <AssetsFile> assetsfileList) { var sourceFile = preloadData.sourceFile; var reader = preloadData.InitReader(); m_Name = reader.ReadAlignedString(); if (readSwitch) { var m_Loop = reader.ReadBoolean(); reader.AlignStream(4); //PPtr<AudioClip> sourceFile.ReadPPtr(sharedFileIndex, assetsfileList); var size = reader.ReadInt32(); m_MovieData = reader.ReadBytes(size); var m_ColorSpace = reader.ReadInt32(); } else { preloadData.extension = ".ogv"; preloadData.FullName = m_Name; } }