public FormStringTable(string variable) { try { InitializeComponent(); this.ShowHint = DockState.Document; Text = AssetCabinet.ToString((Component)Gui.Scripting.Variables[variable]); ToolTipText = ((Component)Gui.Scripting.Variables[variable]).file.Parser.FilePath + @"\" + Text; ParserVar = variable; Gui.Docking.ShowDockContent(this, Gui.Docking.DockEditors, ContentCategory.Others); if (Gui.Scripting.Variables[ParserVar] is MonoBehaviour) { checkBoxJoin.Enabled = false; } else { buttonLastValue.Enabled = false; } checkBoxJoin.CheckedChanged += checkBoxJoin_CheckedChanged; LoadContents(); dataGridViewContents.CellValueChanged += dataGridViewContents_CellValueChanged; } catch (Exception ex) { Utility.ReportException(ex); } }
public FormMonoBehaviour(UnityParser uParser, string parserVar) { try { InitializeComponent(); this.ShowHint = DockState.Document; MonoBehaviour parser = (MonoBehaviour)Gui.Scripting.Variables[parserVar]; this.Text = AssetCabinet.ToString(parser); this.ToolTipText = uParser.FilePath + @"\" + this.Text; EditorVar = Gui.Scripting.GetNextVariable("monoBehaviourEditor"); Editor = (MonoBehaviourEditor)Gui.Scripting.RunScript(EditorVar + " = MonoBehaviourEditor(parser=" + parserVar + ")"); toolTip1.SetToolTip(buttonRevert, DateTime.Now.ToString()); Gui.Docking.ShowDockContent(this, Gui.Docking.DockEditors, ContentCategory.Others); float treeViewFontSize = (float)Gui.Config["TreeViewFontSize"]; if (treeViewFontSize > 0) { treeViewAdditionalMembers.Font = new Font(treeViewAdditionalMembers.Font.Name, treeViewFontSize); } LoadContents(); } catch (Exception e) { Utility.ReportException(e); } }
public FormAssetBundleManifest(string variable) { try { InitializeComponent(); this.ShowHint = DockState.Document; AssetBundleManifest manifest = (AssetBundleManifest)Gui.Scripting.Variables[variable]; Text = AssetCabinet.ToString(manifest); ToolTipText = manifest.file.Parser.FilePath + @"\" + Text; ParserVar = variable; EditorVar = Gui.Scripting.GetNextVariable("manifestEditor"); Editor = (AssetBundleManifestEditor)Gui.Scripting.RunScript(EditorVar + " = AssetBundleManifestEditor(parser=" + ParserVar + ")"); Gui.Docking.ShowDockContent(this, Gui.Docking.DockEditors, ContentCategory.Others); Init(); dataGridViewManifest.Focus(); LoadManifest(); } catch (Exception e) { Utility.ReportException(e); } }
public Component FindTexture(string name) { Component texFound = Textures.Find ( delegate(Component tex) { return((tex is NotLoaded ? ((NotLoaded)tex).Name : AssetCabinet.ToString(tex)) == name); } ); return(texFound); }
private void editTextBoxValue_AfterEditTextChanged(object sender, EventArgs e) { try { if (treeViewAdditionalMembers.SelectedNode == null) { ReselectEditedNode(); } int line = int.Parse(treeViewAdditionalMembers.SelectedNode.Name); Gui.Scripting.RunScript(EditorVar + ".SetExtendedAttributes(line=" + line + ", value=\"" + editTextBoxValue.Text + "\")"); Changed = Changed; AddChange(new Tuple <int, string, int>(line, editTextBoxValue.Text, 0)); TreeNode node = treeViewAdditionalMembers.SelectedNode; if (((string)node.Tag).Contains("PPtr<")) { string name = null; Int64 pathID = 0; if (Int64.TryParse(editTextBoxValue.Text, out pathID) && pathID != 0) { Component asset = Editor.Parser.file.findComponent[pathID]; name = (asset is NotLoaded ? ((NotLoaded)asset).Name : AssetCabinet.ToString(asset)) + " PathID="; } node.Text = node.Tag + ": " + name + editTextBoxValue.Text; } else { node.Text = node.Tag + ": " + editTextBoxValue.Text; } node.BackColor = Color.SeaGreen; treeViewAdditionalMembers.SelectedNode = null; } catch (Exception ex) { Utility.ReportException(ex); } }
public void CopyTo(Animator dest) { if (file.Bundle.numContainerEntries(m_GameObject.instance.m_Name, UnityClassID.GameObject) > 1) { Report.ReportLog("Warning! Animator " + m_GameObject.instance.m_Name + " has multiple entries in the AssetBundle's Container."); } dest.file.Bundle.AddComponent(m_GameObject.instance.m_Name, dest.m_GameObject.instance); dest.m_Enabled = m_Enabled; dest.m_Avatar = new PPtr <Avatar>(m_Avatar.instance != null ? m_Avatar.instance.Clone(dest.file) : null); dest.m_Controller = new PPtr <RuntimeAnimatorController>((Component)null); if (m_Controller.asset != null) { Report.ReportLog("Warning! " + m_Controller.asset.classID1 + " " + AssetCabinet.ToString(m_Controller.asset) + " not duplicated!"); } dest.m_CullingMode = m_CullingMode; dest.m_UpdateMode = m_UpdateMode; dest.m_ApplyRootMotion = m_ApplyRootMotion; dest.m_HasTransformHierarchy = m_HasTransformHierarchy; dest.m_AllowConstantClipSamplingOptimization = m_AllowConstantClipSamplingOptimization; }
public void CopyTo(Animator dest) { bool multiEntry = file.Bundle != null && file.Bundle.numContainerEntries(m_GameObject.instance.m_Name, UnityClassID.GameObject) > 1; dest.m_Enabled = m_Enabled; dest.m_Avatar = new PPtr <Avatar> ( m_Avatar.instance != null && m_Avatar.instance.classID() == UnityClassID.Avatar ? m_Avatar.instance.Clone(dest.file) : null ); if (dest.file.Bundle != null) { if (multiEntry) { dest.file.Bundle.AddComponents(m_GameObject.instance.m_Name, new List <Component>(new Component[2] { dest.m_GameObject.instance, dest.m_Avatar.instance })); } else { dest.file.Bundle.AddComponent(m_GameObject.instance.m_Name, dest.m_GameObject.instance); } } dest.m_Controller = new PPtr <AnimatorController>((Component)null); if (m_Controller.asset != null) { Report.ReportLog("Warning! " + m_Controller.asset.classID() + " " + AssetCabinet.ToString(m_Controller.asset) + " not duplicated!"); } dest.m_CullingMode = m_CullingMode; dest.m_UpdateMode = m_UpdateMode; dest.m_ApplyRootMotion = m_ApplyRootMotion; dest.m_LinearVelocityBlending = m_LinearVelocityBlending; dest.m_HasTransformHierarchy = m_HasTransformHierarchy; dest.m_AllowConstantClipSamplingOptimization = m_AllowConstantClipSamplingOptimization; }
public void Dump() { string msg = String.Empty; for (int i = 0; i < m_PreloadTable.Count; i++) { PPtr <Object> objPtr = m_PreloadTable[i]; if (objPtr.m_FileID == 0) { Component comp = file.FindComponent(objPtr.asset.pathID); if (comp == null) { comp = new NotLoaded(file, objPtr.asset.pathID, 0, 0); } //if (comp.classID1 == UnityClassID.Material // comp.pathID != 0 && comp.classID1 != UnityClassID.GameObject && comp.classID1 != UnityClassID.Transform) { msg += i + " PathID=" + objPtr.asset.pathID + " " + comp.classID1 + " " + (!(comp is NotLoaded) ? AssetCabinet.ToString(comp) : ((NotLoaded)comp).Name) + "\r\n"; } } else { msg += i + " external FileID=" + objPtr.m_FileID + " PathID=" + objPtr.m_PathID + "\r\n"; } } Report.ReportLog(msg); msg = string.Empty; for (int i = 0; i < m_Container.Count; i++) { if (m_Container[i].Value.asset.asset.pathID != 0) { Component asset = file.FindComponent(m_Container[i].Value.asset.asset.pathID); msg += i + " " + m_Container[i].Key + " PathID=" + m_Container[i].Value.asset.asset.pathID + " i=" + m_Container[i].Value.preloadIndex + " s=" + m_Container[i].Value.preloadSize + " " + asset.classID1.ToString() + " " + (asset is NotLoaded ? ((NotLoaded)asset).Name : AssetCabinet.ToString(asset)) + "\r\n"; } else { msg += "NULL! " + i + " " + m_Container[i].Key + " PathID=" + m_Container[i].Value.asset.asset.pathID + " i=" + m_Container[i].Value.preloadIndex + " s=" + m_Container[i].Value.preloadSize + " NULL!\r\n"; } } Report.ReportLog(msg); if (m_MainAsset.asset.asset != null) { Component asset = file.FindComponent(m_MainAsset.asset.asset.pathID); msg = "Main Asset i=" + m_MainAsset.preloadIndex + " s=" + m_MainAsset.preloadSize + " " + asset.classID1.ToString() + " " + (asset is NotLoaded ? ((NotLoaded)asset).Name : AssetCabinet.ToString(asset)); Report.ReportLog(msg); } }
private void UpdateComponent(Component asset, List <Tuple <List <PPtr <Object> >, List <KeyValuePair <string, AssetInfo> > > > containerGroups) { List <Component> assets = new List <Component>(); List <Component> transforms = new List <Component>(); List <Component> containerRelated = new List <Component>(); GetDependantAssets(asset, assets, transforms, containerRelated); if (asset.classID1 == UnityClassID.GameObject) { GameObject gameObj = (GameObject)asset; Animator animator = gameObj.FindLinkedComponent(UnityClassID.Animator); if (animator == null) { foreach (Component trans in transforms) { GetDependantAssets(trans, assets, null, null); } animator = new Animator(null, 0, UnityClassID.Animator, UnityClassID.Animator); animator.m_Avatar = new PPtr <Avatar>((Component)null); animator.m_Controller = new PPtr <RuntimeAnimatorController>((Component)null); GetDependantAssets(animator, assets, transforms, containerRelated); assets.Remove(animator); } } foreach (var group in containerGroups) { var preloadPart = group.Item1; var containerEntries = group.Item2; for (int i = 0; i < containerEntries.Count; i++) { var assetPair = containerEntries[i]; if (assetPair.Value.asset.asset == asset) { preloadPart.Clear(); for (int j = 0; j < assets.Count; j++) { if (assets[j] is ExternalAsset) { ExternalAsset extAsset = (ExternalAsset)assets[j]; PPtr <Object> preloadEntry = new PPtr <Object>((Component)null); preloadEntry.m_FileID = extAsset.FileID; preloadEntry.m_PathID = extAsset.PathID; preloadPart.Add(preloadEntry); } else { preloadPart.Add(new PPtr <Object>(assets[j])); } } string groupName = containerEntries[0].Key; string assetName = AssetCabinet.ToString(asset); if (String.Compare(groupName, assetName, true) != 0) { groupName = assetName.ToLower(); } if (containerEntries.Count > 1) { for (int j = 0; j < containerEntries.Count; j++) { switch (containerEntries[j].Value.asset.asset.classID1) { case UnityClassID.Mesh: case UnityClassID.AnimationClip: containerEntries.RemoveAt(j); j--; break; } } for (int j = containerRelated.Count - 1; j >= 0; j--) { AnimationClip clip = containerRelated[j] as AnimationClip; if (clip != null) { AssetInfo info = new AssetInfo(file); info.asset = new PPtr <Object>(clip); containerEntries.Insert(1, new KeyValuePair <string, AssetInfo>(groupName, info)); } } for (int j = containerRelated.Count - 1; j >= 0; j--) { MeshRenderer meshR = containerRelated[j] as MeshRenderer; if (meshR != null) { Mesh mesh = Operations.GetMesh(meshR); if (mesh != null) { AssetInfo info = new AssetInfo(file); info.asset = new PPtr <Object>(mesh); containerEntries.Insert(1, new KeyValuePair <string, AssetInfo>(groupName, info)); } } } for (int j = 0; j < containerEntries.Count; j++) { containerEntries[j].Value.preloadSize = assets.Count; } } else { containerEntries[0].Value.preloadSize = assets.Count; } for (int j = 0; j < containerEntries.Count; j++) { if (containerEntries[j].Key != groupName) { containerEntries[j] = new KeyValuePair <string, AssetInfo>(groupName, containerEntries[j].Value); } } return; } } } }
public void AddComponent(Component asset) { AddComponent(AssetCabinet.ToString(asset), asset); }
public override void CopyTo(UType dest) { Component asset = null; if (Value.asset != null) { string name = AssetCabinet.ToString(Value.asset); asset = ((UPPtr)dest).file.Bundle.FindComponent(name, Value.asset.classID2); if (asset == null) { switch (Value.asset.classID2) { case UnityClassID.GameObject: if (((UPPtr)dest).Value == null) { Report.ReportLog("Warning! Unset MonoBehaviour to GameObject " + name); break; } return; case UnityClassID.MonoBehaviour: if (((MonoBehaviour)Value.asset).m_GameObject.instance != null) { Transform trans = Operations.FindFrame(name, AnimatorRoot); if (trans != null) { AssetCabinet.TypeDefinition srcDef = this.file.Types.Find ( delegate(AssetCabinet.TypeDefinition def) { return(def.typeId == (int)((MonoBehaviour)Value.asset).classID1); } ); bool found = false; var m_Component = trans.m_GameObject.instance.m_Component; for (int i = 0; i < m_Component.Count; i++) { if (m_Component[i].Value.asset != null && m_Component[i].Value.asset.classID2 == UnityClassID.MonoBehaviour) { AssetCabinet.TypeDefinition destDef = ((UPPtr)dest).file.Types.Find ( delegate(AssetCabinet.TypeDefinition def) { return(def.typeId == (int)((MonoBehaviour)m_Component[i].Value.asset).classID1); } ); if (AssetCabinet.CompareTypes(destDef, srcDef)) { asset = m_Component[i].Value.asset; found = true; break; } } } if (!found) { asset = ((MonoBehaviour)Value.asset).Clone(((UPPtr)dest).file); trans.m_GameObject.instance.AddLinkedComponent((LinkedByGameObject)asset); } } else { Report.ReportLog("Error! MonoBehaviour reference to " + name + " lost. Member " + Name); } } else { asset = ((MonoBehaviour)Value.asset).Clone(((UPPtr)dest).file); } break; case UnityClassID.MonoScript: asset = ((MonoScript)Value.asset).Clone(((UPPtr)dest).file); break; case UnityClassID.Transform: asset = Operations.FindFrame(name, AnimatorRoot); if (asset == null) { Report.ReportLog("Warning! Transform reference to " + name + " lost. Member " + Name); } break; case UnityClassID.Texture2D: asset = ((Texture2D)Value.asset).Clone(((UPPtr)dest).file); break; default: Report.ReportLog("Warning! MonoBehaviour reference to " + Value.asset.classID2 + " " + name + " unhandled. Member " + Name); break; } } } ((UPPtr)dest).Value = new PPtr <Object>(asset); }
public string[] GetAssetNames(bool filter) { string[] assetNames = new string[Parser.Cabinet.Components.Count]; using (BinaryReader reader = new BinaryReader(File.OpenRead(Parser.FilePath))) { Stream stream = reader.BaseStream; for (int i = 0; i < Parser.Cabinet.Components.Count; i++) { NotLoaded comp = Parser.Cabinet.Components[i] as NotLoaded; if (comp == null) { Component subfile = Parser.Cabinet.Components[i]; assetNames[i] = AssetCabinet.ToString(subfile); continue; } if (comp.Name == null) { stream.Position = comp.offset; switch (comp.classID1) { case UnityClassID.AssetBundle: case UnityClassID.Avatar: case UnityClassID.Mesh: if (!filter) { comp.Name = reader.ReadNameA4(); } break; case UnityClassID.AudioClip: case UnityClassID.AnimationClip: case UnityClassID.AnimatorController: case UnityClassID.AnimatorOverrideController: case UnityClassID.Cubemap: case UnityClassID.Material: case UnityClassID.Shader: case UnityClassID.Sprite: case UnityClassID.TextAsset: case UnityClassID.Texture2D: comp.Name = reader.ReadNameA4(); break; case UnityClassID.MonoScript: comp.Name = comp.pathID + " / " + reader.ReadNameA4(); break; case UnityClassID.Animator: case UnityClassID.EllipsoidParticleEmitter: case UnityClassID.Light: case UnityClassID.ParticleAnimator: case UnityClassID.ParticleRenderer: case UnityClassID.ParticleSystem: case UnityClassID.ParticleSystemRenderer: comp.Name = GetNameFromGameObject(filter, stream); break; default: if ((int)comp.classID1 <= -1 && comp.classID2 == UnityClassID.MonoBehaviour) { comp.Name = GetNameFromGameObject(filter, stream); if (comp.Name == null) { comp.Name = MonoBehaviour.LoadName(stream); } } break; case UnityClassID.AudioListener: case UnityClassID.AudioSource: case UnityClassID.BoxCollider: case UnityClassID.Camera: case UnityClassID.CapsuleCollider: case UnityClassID.FlareLayer: case UnityClassID.LinkToGameObject: case UnityClassID.LinkToGameObject223: case UnityClassID.LinkToGameObject225: case UnityClassID.MeshCollider: case UnityClassID.MeshFilter: case UnityClassID.MeshRenderer: case UnityClassID.MultiLink: case UnityClassID.Projector: case UnityClassID.Rigidbody: case UnityClassID.SkinnedMeshRenderer: case UnityClassID.SphereCollider: case UnityClassID.SpriteRenderer: case UnityClassID.Transform: if (!filter) { comp.Name = GetNameFromGameObject(true, stream); } break; case UnityClassID.GameObject: if (!filter || IsVirtualAnimator(comp)) { comp.Name = GameObject.LoadName(stream); } break; } } assetNames[i] = comp.Name != null ? comp.Name : comp.pathID.ToString(); } } return(assetNames); }
public static void CreateMember(ref int line, UType utype, int arrayIndex, TreeNodeCollection nodes) { if (utype is UClass) { if (((UClass)utype).ClassName == "string") { CreateTreeNode(line, nodes, utype.Name, " (string)", ((UClass)utype).GetString(), arrayIndex); } else if (((UClass)utype).ClassName == "Vector2f") { string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString(); CreateTreeNode(line, nodes, utype.Name, " (Vector2f)", value, arrayIndex); } else if (((UClass)utype).ClassName == "Vector3f") { string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString(); CreateTreeNode(line, nodes, utype.Name, " (Vector3f)", value, arrayIndex); } else if (((UClass)utype).ClassName == "Vector4f") { string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[3]).Value.ToFloatString(); CreateTreeNode(line, nodes, utype.Name, " (Vector4f)", value, arrayIndex); } else if (((UClass)utype).ClassName == "Quaternionf") { string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[3]).Value.ToFloatString(); CreateTreeNode(line, nodes, utype.Name, " (Quaternionf)", value, arrayIndex); } else if (((UClass)utype).ClassName == "ColorRGBA" && ((UClass)utype).Members.Count == 4) { string value = ((Ufloat)((UClass)utype).Members[0]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[1]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[2]).Value.ToFloatString() + ", " + ((Ufloat)((UClass)utype).Members[3]).Value.ToFloatString(); CreateTreeNode(line, nodes, utype.Name, " (ColorRGBA)", value, arrayIndex); } else { TreeNode classNode = CreateTreeNode(line, nodes, utype.Name, " " + ((UClass)utype).ClassName, null, arrayIndex, false); line++; for (int i = 0; i < ((UClass)utype).Members.Count; i++) { CreateMember(ref line, ((UClass)utype).Members[i], -1, classNode.Nodes); } line--; } } else if (utype is UPPtr) { UPPtr ptr = (UPPtr)utype; Component asset = ptr.Value != null ? ptr.Value.asset : null; CreateTreeNode(line, nodes, utype.Name, " (PPtr<" + (asset != null ? asset.classID().ToString() : "") + ">)", ptr.Value != null ? (asset != null ? asset is NotLoaded ? ((NotLoaded)asset).Name : AssetCabinet.ToString(asset) : String.Empty) + " PathID=" + ptr.Value.m_PathID : null, arrayIndex); } else if (utype is Uarray) { TreeNode arrayNode = CreateTreeNode(line, nodes, "", "Array size " + (((Uarray)utype).Value != null ? ((Uarray)utype).Value.Length : 0), null, arrayIndex, false); arrayNode.Tag = utype; line++; if (((Uarray)utype).Value != null) { for (int i = 0; i < ((Uarray)utype).Value.Length; i++) { CreateMember(ref line, ((Uarray)utype).Value[i], i, arrayNode.Nodes); } } line--; } else if (utype is Ufloat) { CreateTreeNode(line, nodes, utype.Name, " (float)", ((Ufloat)utype).Value.ToFloatString(), arrayIndex); } else if (utype is Udouble) { CreateTreeNode(line, nodes, utype.Name, " (double)", ((Udouble)utype).Value.ToDoubleString(), arrayIndex); } else if (utype is Uint8) { CreateTreeNode(line, nodes, utype.Name, " (int8)", ((Uint8)utype).Value.ToString(), arrayIndex); } else if (utype is Uint16) { CreateTreeNode(line, nodes, utype.Name, " (int16)", ((Uint16)utype).Value.ToString(), arrayIndex); } else if (utype is Uuint16) { CreateTreeNode(line, nodes, utype.Name, " (uint16)", ((Uuint16)utype).Value.ToString(), arrayIndex); } else if (utype is Uint32) { CreateTreeNode(line, nodes, utype.Name, " (int32)", ((Uint32)utype).Value.ToString(), arrayIndex); } else if (utype is Uuint32) { CreateTreeNode(line, nodes, utype.Name, " (uint32)", ((Uuint32)utype).Value.ToString(), arrayIndex); } else if (utype is Uint64) { CreateTreeNode(line, nodes, utype.Name, " (int64)", ((Uint64)utype).Value.ToString(), arrayIndex); } else if (utype is Uuint64) { CreateTreeNode(line, nodes, utype.Name, " (uint64)", ((Uuint64)utype).Value.ToString(), arrayIndex); } else { CreateTreeNode(line, nodes, utype.Name, " " + utype.GetType() + " unhandled", null, arrayIndex, false); } line++; }
public void Export(string path) { DirectoryInfo dirInfo = new DirectoryInfo(path); if (!dirInfo.Exists) { dirInfo.Create(); } using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(path + "\\" + m_Name + "." + UnityClassID.Shader), System.Text.Encoding.UTF8)) { writer.Write(System.Text.Encoding.UTF8.GetBytes(m_Script)); writer.Write(System.Text.Encoding.UTF8.GetBytes("\n// Dependencies:\n")); foreach (PPtr <Shader> shaderPtr in m_Dependencies) { Component shader = shaderPtr.asset; writer.Write(System.Text.Encoding.UTF8.GetBytes("//\t" + (shader != null ? shader.classID1 + " " + AssetCabinet.ToString(shader) : "NULL") + "\n")); } writer.BaseStream.SetLength(writer.BaseStream.Position); } }
public override void CopyTo(UType dest) { Component asset = null; if (Value.asset != null) { string name = AssetCabinet.ToString(Value.asset); asset = ((UPPtr)dest).file.Bundle.FindComponent(name, Value.asset.classID()); if (asset == null) { switch (Value.asset.classID()) { case UnityClassID.GameObject: if (((UPPtr)dest).Value == null) { GameObject gObj = (GameObject)Value.asset; if (gObj != null) { Transform trans = gObj.FindLinkedComponent(typeof(Transform)); trans = AnimatorRoot != null?Operations.FindFrame(trans.GetTransformPath(), AnimatorRoot) : null; if (trans != null) { asset = trans.m_GameObject.instance; break; } } Report.ReportLog("Warning! Losing PPtr<" + Value.asset.classID() + "> " + Name + " to " + name); break; } return; case UnityClassID.Light: GameObject gameObj = ((Light)Value.asset).m_GameObject.instance; if (gameObj != null) { Transform trans = gameObj.FindLinkedComponent(typeof(Transform)); trans = AnimatorRoot != null?Operations.FindFrame(trans.GetTransformPath(), AnimatorRoot) : null; if (trans != null) { asset = trans.m_GameObject.instance.FindLinkedComponent(UnityClassID.Light); } else { foreach (Component a in ((UPPtr)dest).file.Components) { if (a.classID() == UnityClassID.Light) { string n = a is NotLoaded ? ((NotLoaded)a).Name : AssetCabinet.ToString(a); if (n == name) { asset = a; Report.ReportLog("Warning! Unsharp search for PPtr<" + Value.asset.classID() + "> " + Name + " to " + name + " found PathID=" + a.pathID); break; } } } if (asset == null) { Report.ReportLog("Warning! Losing PPtr<" + Value.asset.classID() + "> " + Name + " to " + name); } } } break; case UnityClassID.MonoBehaviour: gameObj = ((MonoBehaviour)Value.asset).m_GameObject.instance; if (gameObj != null) { Transform trans = gameObj.FindLinkedComponent(typeof(Transform)); trans = AnimatorRoot != null?Operations.FindFrame(trans.GetTransformPath(), AnimatorRoot) : null; if (trans != null) { AssetCabinet.TypeDefinition srcDef = this.file.VersionNumber < AssetCabinet.VERSION_5_5_0 ? this.file.Types.Find ( delegate(AssetCabinet.TypeDefinition def) { return(def.typeId == (int)((MonoBehaviour)Value.asset).classID1); } ) : this.file.Types[(int)((MonoBehaviour)Value.asset).classID1]; bool found = false; var m_Component = trans.m_GameObject.instance.m_Component; for (int i = 0; i < m_Component.Count; i++) { if (m_Component[i].Value.asset != null && m_Component[i].Value.asset.classID() == UnityClassID.MonoBehaviour) { AssetCabinet.TypeDefinition destDef = ((UPPtr)dest).file.VersionNumber < AssetCabinet.VERSION_5_5_0 ? ((UPPtr)dest).file.Types.Find ( delegate(AssetCabinet.TypeDefinition def) { return(def.typeId == (int)((MonoBehaviour)m_Component[i].Value.asset).classID1); } ) : ((UPPtr)dest).file.Types[(int)((MonoBehaviour)m_Component[i].Value.asset).classID1]; if (AssetCabinet.CompareTypes(destDef, srcDef)) { asset = m_Component[i].Value.asset; found = true; break; } } } if (!found) { asset = ((MonoBehaviour)Value.asset).Clone(((UPPtr)dest).file); trans.m_GameObject.instance.AddLinkedComponent((LinkedByGameObject)asset); } } else { Report.ReportLog("Error! Reference to " + Value.asset.classID() + " " + name + " lost. Member " + Name); } } else { asset = ((MonoBehaviour)Value.asset).Clone(((UPPtr)dest).file); } break; case UnityClassID.MonoScript: asset = ((MonoScript)Value.asset).Clone(((UPPtr)dest).file); break; case UnityClassID.Sprite: asset = ((Sprite)Value.asset).Clone(((UPPtr)dest).file); break; case UnityClassID.Transform: asset = AnimatorRoot != null?Operations.FindFrame(((Transform)Value.asset).GetTransformPath(), AnimatorRoot) : null; if (asset == null) { Report.ReportLog("Warning! Reference to " + UnityClassID.Transform + " " + name + " lost. Member " + Name); } break; case UnityClassID.Material: asset = ((Material)Value.asset).Clone(((UPPtr)dest).file); break; case UnityClassID.MeshRenderer: case UnityClassID.SkinnedMeshRenderer: asset = AnimatorRoot != null?Operations.FindMesh(AnimatorRoot, name) : null; if (asset == null) { Report.ReportLog("Warning! Reference to " + Value.asset.classID() + " " + name + " lost. Member " + Name); } break; case UnityClassID.Texture2D: asset = ((Texture2D)Value.asset).Clone(((UPPtr)dest).file); break; case UnityClassID.Cubemap: asset = ((Cubemap)Value.asset).Clone(((UPPtr)dest).file); break; default: if (Value.asset is LoadedByTypeDefinition) { LoadedByTypeDefinition loadedByTypeDef = (LoadedByTypeDefinition)Value.asset; PPtr <GameObject> gameObjPtr = loadedByTypeDef.m_GameObject; if (gameObjPtr == null) { AssetCabinet file = ((UPPtr)dest).file; foreach (Component a in file.Components) { if (a.classID() == loadedByTypeDef.classID() && (a is NotLoaded ? ((NotLoaded)a).Name : AssetCabinet.ToString(a)) == loadedByTypeDef.m_Name) { asset = a; file = null; break; } } if (file != null) { asset = loadedByTypeDef.Clone(file); } } else { Transform srcTrans = gameObjPtr.instance.FindLinkedComponent(typeof(Transform)); Transform destTrans = AnimatorRoot != null?Operations.FindFrame(srcTrans.GetTransformPath(), AnimatorRoot) : null; if (destTrans != null) { asset = destTrans.m_GameObject.instance.FindLinkedComponent(loadedByTypeDef.classID()); } else { foreach (Component a in ((UPPtr)dest).file.Components) { if (a.classID() == Value.asset.classID()) { string n = a is NotLoaded ? ((NotLoaded)a).Name : AssetCabinet.ToString(a); if (n == name) { asset = a; Report.ReportLog("Warning! Unsharp search for PPtr<" + Value.asset.classID() + "> " + Name + " to " + name + " found PathID=" + a.pathID); break; } } } if (asset == null) { Report.ReportLog("Warning! Losing PPtr<" + Value.asset.classID() + "> " + Name + " to " + name); } } } } else { Report.ReportLog("Warning! Reference to " + Value.asset.classID() + " " + name + " unhandled. Member " + Name); } break; } } } ((UPPtr)dest).Value = new PPtr <Object>(asset); }