public new RectTransform Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.RectTransform); RectTransform clone = new RectTransform(file); clone.m_LocalRotation = m_LocalRotation; clone.m_LocalPosition = m_LocalPosition; clone.m_LocalScale = m_LocalScale; clone.m_AnchorMin = m_AnchorMin; clone.m_AnchorMax = m_AnchorMax; clone.m_AnchoredPosition = m_AnchoredPosition; clone.m_SizeDelta = m_SizeDelta; clone.m_Pivot = m_Pivot; clone.InitChildren(Count); for (int i = 0; i < Count; i++) { GameObject gameObj = this[i].m_GameObject.instance.Clone(file); clone.AddChild(gameObj.FindLinkedComponent(typeof(RectTransform))); } return(clone); }
public Animator Clone(AssetCabinet file) { Component gameObj = file.Bundle.FindComponent(m_GameObject.instance.m_Name, UnityClassID.GameObject); if (gameObj == null) { file.MergeTypeDefinition(this.file, UnityClassID.Animator); Animator dest = new Animator(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, dest)); return(dest); } else if (gameObj is NotLoaded) { NotLoaded notLoaded = (NotLoaded)gameObj; if (notLoaded.replacement != null) { gameObj = notLoaded.replacement; } else { gameObj = file.LoadComponent(file.SourceStream, notLoaded); } } return(((GameObject)gameObj).FindLinkedComponent(UnityClassID.Animator)); }
public Avatar Clone(AssetCabinet file) { Component avatar = file.Components.Find ( delegate(Component asset) { return(asset.classID1 == UnityClassID.Avatar && (asset is NotLoaded ? ((NotLoaded)asset).Name : ((Avatar)asset).m_Name) == m_Name); } ); if (avatar == null) { file.MergeTypeDefinition(this.file, UnityClassID.Avatar); Avatar dest = new Avatar(file); using (MemoryStream mem = new MemoryStream()) { this.WriteTo(mem); mem.Position = 0; dest.LoadFrom(mem); } return(dest); } else if (avatar is NotLoaded) { NotLoaded notLoaded = (NotLoaded)avatar; avatar = file.LoadComponent(file.SourceStream, notLoaded); } return((Avatar)avatar); }
public Texture2D Clone(AssetCabinet file) { Component tex = file.Bundle != null ? file.Bundle.FindComponent(m_Name, UnityClassID.Texture2D) : file.Parser.GetTexture(m_Name); if (tex == null) { file.MergeTypeDefinition(this.file, UnityClassID.Texture2D); tex = new Texture2D(file); if (file.Bundle != null) { file.Bundle.AddComponent(m_Name, tex); } CopyAttributesTo((Texture2D)tex); CopyImageTo((Texture2D)tex); } else if (tex is NotLoaded) { NotLoaded notLoaded = (NotLoaded)tex; if (notLoaded.replacement != null) { tex = notLoaded.replacement; } else { tex = file.LoadComponent(file.SourceStream, notLoaded); } } return((Texture2D)tex); }
public TextAsset Clone(AssetCabinet file) { Component text = file.Components.Find ( delegate(Component asset) { return(asset.classID1 == UnityClassID.TextAsset && (asset is NotLoaded ? ((NotLoaded)asset).Name : ((TextAsset)asset).m_Name) == m_Name); } ); if (text == null) { file.MergeTypeDefinition(this.file, UnityClassID.TextAsset); TextAsset dest = new TextAsset(file); file.Bundle.AddComponent(m_Name, dest); using (MemoryStream mem = new MemoryStream()) { this.WriteTo(mem); mem.Position = 0; dest.LoadFrom(mem); } return(dest); } else if (text is NotLoaded) { NotLoaded notLoaded = (NotLoaded)text; text = file.LoadComponent(file.SourceStream, notLoaded); } return((TextAsset)text); }
public MonoScript Clone(AssetCabinet file) { Component monoS = file.Bundle.FindComponent(m_Name, UnityClassID.MonoScript); if (monoS == null) { file.MergeTypeDefinition(this.file, UnityClassID.MonoScript); monoS = new MonoScript(file); file.Bundle.AddComponent(m_Name, monoS); using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; monoS.LoadFrom(mem); } } else if (monoS is NotLoaded) { NotLoaded notLoaded = (NotLoaded)monoS; if (notLoaded.replacement != null) { monoS = notLoaded.replacement; } else { monoS = file.LoadComponent(file.SourceStream, notLoaded); } } return((MonoScript)monoS); }
public Material Clone(AssetCabinet file, bool cloneTextures) { Component mat = file.Bundle != null?file.Bundle.FindComponent(m_Name, UnityClassID.Material) : null; if (mat == null) { file.MergeTypeDefinition(this.file, UnityClassID.Material); mat = new Material(file); if (file.Bundle != null) { file.Bundle.AddComponent(m_Name, mat); } CopyTo((Material)mat, cloneTextures); } else if (mat is NotLoaded) { NotLoaded notLoaded = (NotLoaded)mat; if (notLoaded.replacement != null) { mat = notLoaded.replacement; } else { mat = file.LoadComponent(file.SourceStream, notLoaded); } } return((Material)mat); }
public new Cubemap Clone(AssetCabinet file) { Component cubemap = file.Bundle.FindComponent(m_Name, UnityClassID.Cubemap); if (cubemap == null) { file.MergeTypeDefinition(this.file, UnityClassID.Cubemap); Cubemap clone = new Cubemap(file); file.Bundle.AddComponent(m_Name, clone); CopyAttributesTo(clone); CopyImageTo(clone); foreach (PPtr<Texture2D> texPtr in m_SourceTextures) { if (texPtr.asset != null) { clone.m_SourceTextures.Add(new PPtr<Texture2D>(texPtr.instance.Clone(file))); } } return clone; } else if (cubemap is NotLoaded) { NotLoaded notLoaded = (NotLoaded)cubemap; if (notLoaded.replacement != null) { cubemap = notLoaded.replacement; } else { cubemap = file.LoadComponent(file.SourceStream, notLoaded); } } return (Cubemap)cubemap; }
public new Cubemap Clone(AssetCabinet file) { Component cubemap = file.Bundle.FindComponent(m_Name, UnityClassID.Cubemap); if (cubemap == null) { file.MergeTypeDefinition(this.file, UnityClassID.Cubemap); Cubemap clone = new Cubemap(file); file.Bundle.AddComponent(m_Name, clone); CopyAttributesTo(clone); CopyImageTo(clone); foreach (PPtr <Texture2D> texPtr in m_SourceTextures) { if (texPtr.asset != null) { clone.m_SourceTextures.Add(new PPtr <Texture2D>(texPtr.instance.Clone(file))); } } return(clone); } else if (cubemap is NotLoaded) { NotLoaded notLoaded = (NotLoaded)cubemap; if (notLoaded.replacement != null) { cubemap = notLoaded.replacement; } else { cubemap = file.LoadComponent(file.SourceStream, notLoaded); } } return((Cubemap)cubemap); }
public AnimationClip Clone(AssetCabinet file) { Component clip = file.Components.Find ( delegate(Component asset) { return(asset.classID() == UnityClassID.AnimationClip && (asset is NotLoaded ? ((NotLoaded)asset).Name : ((AnimationClip)asset).m_Name) == m_Name); } ); if (clip == null) { file.MergeTypeDefinition(this.file, UnityClassID.AnimationClip); clip = new AnimationClip(file); } else if (clip is NotLoaded) { NotLoaded notLoaded = (NotLoaded)clip; clip = file.LoadComponent(file.SourceStream, notLoaded); } using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; clip.LoadFrom(mem); } return((AnimationClip)clip); }
public MeshFilter Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.MeshFilter); MeshFilter filter = new MeshFilter(file); filter.m_Mesh = new PPtr<Mesh>(m_Mesh.instance != null ? m_Mesh.instance.Clone(file) : null); return filter; }
public MonoScript Clone(AssetCabinet file) { Component monoS; if (file.VersionNumber < AssetCabinet.VERSION_5_0_0) { monoS = file.Bundle.FindComponent(m_Name, UnityClassID.MonoScript); } else { string searchName = " / " + m_Name; PPtr <Object> ms = file.AssetRefs.Find ( delegate(PPtr <Object> objPtr) { return(objPtr.asset != null && ( objPtr.asset is NotLoaded && ((NotLoaded)objPtr.asset).Name.EndsWith(searchName) || objPtr.asset is MonoScript && ((MonoScript)objPtr.asset).m_Name == m_Name )); } ); monoS = ms != null ? ms.asset : null; } if (monoS == null) { file.MergeTypeDefinition(this.file, UnityClassID.MonoScript); monoS = new MonoScript(file); if (file.VersionNumber < AssetCabinet.VERSION_5_0_0) { file.Bundle.AddComponent(m_Name, monoS); } else { file.AssetRefs.Add(new PPtr <Object>(monoS)); } using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; monoS.LoadFrom(mem); } } else if (monoS is NotLoaded) { NotLoaded notLoaded = (NotLoaded)monoS; if (notLoaded.replacement != null) { monoS = notLoaded.replacement; } else { monoS = file.LoadComponent(file.SourceStream, notLoaded); } } return((MonoScript)monoS); }
public new LineRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.LineRenderer); LineRenderer lineR = new LineRenderer(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, lineR)); return(lineR); }
public new TrailRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.TrailRenderer); TrailRenderer trailR = new TrailRenderer(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, trailR)); return(trailR); }
public Cloth Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Cloth); Cloth cloth = new Cloth(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, cloth)); return(cloth); }
public MeshRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.MeshRenderer); MeshRenderer meshR = new MeshRenderer(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, meshR)); return(meshR); }
public MeshFilter Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.MeshFilter); MeshFilter filter = new MeshFilter(file); filter.m_Mesh = new PPtr <Mesh>(m_Mesh.instance != null ? m_Mesh.instance.Clone(file) : null); return(filter); }
public new SkinnedMeshRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.SkinnedMeshRenderer); SkinnedMeshRenderer sMesh = new SkinnedMeshRenderer(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, sMesh)); return(sMesh); }
public new ParticleRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.ParticleRenderer); ParticleRenderer partRenderer = new ParticleRenderer(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, partRenderer)); return(partRenderer); }
public Animation Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Animation); Animation dest = new Animation(file); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, dest)); return(dest); }
public Material Clone(AssetCabinet file, bool cloneTextures) { Component mat = file != this.file ? file.Bundle != null && !file.Bundle.m_IsStreamedSceneAssetBundle ? file.Bundle.FindComponent(m_Name, UnityClassID.Material) : file.Components.Find ( delegate(Component asset) { return(asset.classID() == UnityClassID.Material && (asset is NotLoaded ? ((NotLoaded)asset).Name : ((Material)asset).m_Name) == m_Name); } ) : null; if (mat == null) { file.MergeTypeDefinition(this.file, UnityClassID.Material); mat = new Material(file); if (file.Bundle != null && this.file.Bundle != null) { List <Component> externals = new List <Component>(); AssetBundle.AddExternalAssetsFromPreloadTable(this, this.file.Bundle, externals); for (int i = 0; i < externals.Count; i++) { ExternalAsset ext = (ExternalAsset)externals[i]; string assetPath = this.file.References[ext.FileID - 1].assetPath; int cabPos = assetPath.LastIndexOf("/") + 1; if (!AssetCabinet.LoadedCabinets.ContainsKey(assetPath.Substring(cabPos))) { ext.FileID = file.MergeReference(this.file, ext.FileID); } else { externals.RemoveAt(i--); } } file.Bundle.AddComponent(m_Name, mat, externals); } CopyTo((Material)mat, cloneTextures); } else if (mat is NotLoaded) { NotLoaded notLoaded = (NotLoaded)mat; if (notLoaded.replacement != null) { mat = notLoaded.replacement; } else { mat = file.LoadComponent(file.SourceStream, notLoaded); } } return((Material)mat); }
public Light Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Light); Light dest = new Light(file); dest.m_Enabled = m_Enabled; dest.m_Type = m_Type; dest.m_Color = m_Color; dest.m_Intensity = m_Intensity; dest.m_Range = m_Range; dest.m_SpotAngle = m_SpotAngle; dest.m_CookieSize = m_CookieSize; using (MemoryStream mem = new MemoryStream()) { m_Shadows.WriteTo(mem); mem.Position = 0; dest.m_Shadows = new ShadowSettings(mem); } Texture2D tex = null; if (m_Cookie.instance != null) { tex = (Texture2D)dest.file.Bundle.FindComponent(m_Cookie.instance.m_Name, UnityClassID.Texture2D); if (tex == null) { tex = m_Cookie.instance.Clone(dest.file); } } dest.m_Cookie = new PPtr <Texture2D>(tex); dest.m_DrawHalo = m_DrawHalo; dest.m_ActuallyLightmapped = m_ActuallyLightmapped; Flare flare = null; if (m_Flare.instance != null) { Report.ReportLog("Flare not cloned"); } dest.m_Flare = new PPtr <Flare>(flare); dest.m_RenderMode = m_RenderMode; using (MemoryStream mem = new MemoryStream()) { m_CullingMask.WriteTo(mem); mem.Position = 0; dest.m_CullingMask = new BitField(mem); } dest.m_Lightmapping = m_Lightmapping; return(dest); }
public new SkinnedMeshRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.SkinnedMeshRenderer); SkinnedMeshRenderer sMesh = new SkinnedMeshRenderer(file); sMesh.m_Mesh = new PPtr <Mesh>(m_Mesh.instance != null ? m_Mesh.instance.Clone(file) : null); AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, sMesh)); return(sMesh); }
public AnimatorController Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.AnimatorController); AnimatorController dest = new AnimatorController(file); dest.m_Name = m_Name; AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, dest)); return(dest); }
public SphereCollider Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.SphereCollider); SphereCollider clone = new SphereCollider(file); clone.m_Material = new PPtr <PhysicMaterial>(m_Material.instance != null ? m_Material.instance.Clone(clone.file) : null); clone.m_IsTrigger = m_IsTrigger; clone.m_Enabled = m_Enabled; clone.m_Radius = m_Radius; clone.m_Center = m_Center; return(clone); }
public Mesh Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Mesh); Mesh mesh = new Mesh(file); using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; mesh.LoadFrom(mem); } return(mesh); }
public Rigidbody Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Rigidbody); Rigidbody dest = new Rigidbody(file); dest.m_Mass = m_Mass; dest.m_Drag = m_Drag; dest.m_AngularDrag = m_AngularDrag; dest.m_UseGravity = m_UseGravity; dest.m_IsKinematic = m_IsKinematic; dest.m_Interpolate = m_Interpolate; dest.m_Constraints = m_Constraints; dest.m_CollisionDetection = m_CollisionDetection; return(dest); }
public AssetBundle Clone(AssetCabinet file) { if (file.Bundle != null) { return(file.Bundle); } file.MergeTypeDefinition(this.file, UnityClassID.AssetBundle); AssetBundle clone = new AssetBundle(file); clone.pathID = pathID; clone.m_Name = m_Name; clone.m_PreloadTable = new List <PPtr <Object> >(m_PreloadTable.Count); clone.m_PreloadTable.AddRange(m_PreloadTable); clone.m_Container = new List <KeyValuePair <string, AssetInfo> >(file.Components.Count); for (int i = 0; i < m_Container.Count; i++) { var containerEntry = m_Container[i]; bool keepKey = true; int endIdx = containerEntry.Value.preloadIndex + containerEntry.Value.preloadSize; for (int j = containerEntry.Value.preloadIndex; j < endIdx; j++) { if (((NotLoaded)containerEntry.Value.asset.asset).replacement == null) { keepKey = false; break; } } do { if (keepKey) { clone.m_Container.Add(m_Container[i]); } } while (++i < m_Container.Count && containerEntry.Key == m_Container[i].Key); } clone.m_MainAsset = new AssetInfo(file); clone.m_MainAsset.asset = new PPtr <Object>((Component)null); clone.m_ScriptCompatibility = (AssetBundleScriptInfo[])m_ScriptCompatibility.Clone(); clone.m_ClassCompatibility = (KeyValuePair <int, uint>[])m_ClassCompatibility.Clone(); clone.m_RuntimeCompatibility = m_RuntimeCompatibility; return(clone); }
public Shader Clone(AssetCabinet file) { Component sha = file.Bundle != null?file.Bundle.FindComponent(m_Name, UnityClassID.Shader) : null; if (sha == null) { file.MergeTypeDefinition(this.file, UnityClassID.Shader); Shader dest = new Shader(file); if (file.Bundle != null) { file.Bundle.AddComponent(m_Name, dest); } dest.m_Name = m_Name; dest.m_Script = m_Script; dest.m_PathName = m_PathName; foreach (PPtr <Shader> asset in m_Dependencies) { sha = asset.asset; if (sha != null) { Type t = sha.GetType(); MethodInfo info = t.GetMethod("Clone", new Type[] { typeof(AssetCabinet) }); sha = (Component)info.Invoke(sha, new object[] { file }); } dest.m_Dependencies.Add(new PPtr <Shader>(sha)); } dest.m_ShaderIsBaked = m_ShaderIsBaked; return(dest); } else if (sha is NotLoaded) { NotLoaded notLoaded = (NotLoaded)sha; if (notLoaded.replacement != null) { sha = notLoaded.replacement; } else { sha = file.LoadComponent(file.SourceStream, notLoaded); } } return((Shader)sha); }
public Transform Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Transform); Transform trans = new Transform(file); trans.m_LocalRotation = m_LocalRotation; trans.m_LocalPosition = m_LocalPosition; trans.m_LocalScale = m_LocalScale; trans.InitChildren(Count); for (int i = 0; i < Count; i++) { GameObject gameObj = this[i].m_GameObject.instance.Clone(file); trans.AddChild(gameObj.FindLinkedComponent(typeof(Transform))); } return(trans); }
public Mesh Clone(AssetCabinet file) { Mesh mesh = null; foreach (Component a in file.Components) { if (a.classID() == UnityClassID.Mesh) { if (a is NotLoaded && ((NotLoaded)a).Name == m_Name) { mesh = file.LoadComponent(file.SourceStream, (NotLoaded)a); break; } if (a is Mesh && ((Mesh)a).m_Name == m_Name) { mesh = (Mesh)a; break; } } } if (mesh != null) { if (mesh.m_SubMeshes.Count == m_SubMeshes.Count && mesh.m_VertexData.m_VertexCount == m_VertexData.m_VertexCount && mesh.m_IndexBuffer.Length == m_IndexBuffer.Length && mesh.m_LocalAABB.m_Center == m_LocalAABB.m_Center && mesh.m_LocalAABB.m_Extend == m_LocalAABB.m_Extend) { return(mesh); } } else { file.MergeTypeDefinition(this.file, UnityClassID.Mesh); } mesh = new Mesh(file); using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; mesh.LoadFrom(mem); } return(mesh); }
public Sprite Clone(AssetCabinet file) { Component sprite = file.Bundle.FindComponent(m_Name, UnityClassID.Sprite); if (sprite == null) { if (m_RD.texture.instance == null) { throw new Exception("Cant clone textureless Sprite"); } file.MergeTypeDefinition(this.file, UnityClassID.Sprite); Sprite dest = new Sprite(file); dest.m_Name = m_Name; dest.m_Rect = m_Rect.Clone(); dest.m_Offset = m_Offset; dest.m_Border = m_Border; dest.m_PixelsToUnits = m_PixelsToUnits; dest.m_Extrude = m_Extrude; dest.m_IsPolygon = m_IsPolygon; dest.m_RD = m_RD.Clone(file); file.Bundle.UnregisterFromUpdate(dest.m_RD.texture.instance); file.Bundle.AppendComponent(m_RD.texture.instance.m_Name, UnityClassID.Texture2D, dest); file.Bundle.RegisterForUpdate(dest); return(dest); } else if (sprite is NotLoaded) { NotLoaded notLoaded = (NotLoaded)sprite; if (notLoaded.replacement != null) { sprite = notLoaded.replacement; } else { sprite = file.LoadComponent(file.SourceStream, notLoaded); } } return((Sprite)sprite); }
public MonoScript Clone(AssetCabinet file) { Component monoS = file.Bundle.FindComponent(m_Name, UnityClassID.MonoScript); if (monoS == null) { file.MergeTypeDefinition(this.file, UnityClassID.MonoScript); monoS = new MonoScript(file); file.Bundle.AddComponent(m_Name, monoS); using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; monoS.LoadFrom(mem); } } else if (monoS is NotLoaded) { NotLoaded notLoaded = (NotLoaded)monoS; if (notLoaded.replacement != null) { monoS = notLoaded.replacement; } else { monoS = file.LoadComponent(file.SourceStream, notLoaded); } } return (MonoScript)monoS; }
public Avatar Clone(AssetCabinet file) { Component avatar = file.Components.Find ( delegate (Component asset) { return asset.classID1 == UnityClassID.Avatar && (asset is NotLoaded ? ((NotLoaded)asset).Name : ((Avatar)asset).m_Name) == m_Name; } ); if (avatar == null) { file.MergeTypeDefinition(this.file, UnityClassID.Avatar); Avatar dest = new Avatar(file); using (MemoryStream mem = new MemoryStream()) { this.WriteTo(mem); mem.Position = 0; dest.LoadFrom(mem); } return dest; } else if (avatar is NotLoaded) { NotLoaded notLoaded = (NotLoaded)avatar; avatar = file.LoadComponent(file.SourceStream, notLoaded); } return (Avatar)avatar; }
public Shader Clone(AssetCabinet file) { Component sha = file.Bundle != null ? file.Bundle.FindComponent(m_Name, UnityClassID.Shader) : null; if (sha == null) { file.MergeTypeDefinition(this.file, UnityClassID.Shader); Shader dest = new Shader(file); if (file.Bundle != null) { file.Bundle.AddComponent(m_Name, dest); } dest.m_Name = m_Name; dest.m_Script = m_Script; dest.m_PathName = m_PathName; foreach (PPtr<Shader> asset in m_Dependencies) { sha = asset.asset; if (sha != null) { Type t = sha.GetType(); MethodInfo info = t.GetMethod("Clone", new Type[] { typeof(AssetCabinet) }); sha = (Component)info.Invoke(sha, new object[] { file }); } dest.m_Dependencies.Add(new PPtr<Shader>(sha)); } dest.m_ShaderIsBaked = m_ShaderIsBaked; return dest; } else if (sha is NotLoaded) { NotLoaded notLoaded = (NotLoaded)sha; if (notLoaded.replacement != null) { sha = notLoaded.replacement; } else { sha = file.LoadComponent(file.SourceStream, notLoaded); } } return (Shader)sha; }
public Material Clone(AssetCabinet file, bool cloneTextures) { Component mat = file.Bundle != null ? file.Bundle.FindComponent(m_Name, UnityClassID.Material) : null; if (mat == null) { file.MergeTypeDefinition(this.file, UnityClassID.Material); mat = new Material(file); if (file.Bundle != null) { file.Bundle.AddComponent(m_Name, mat); } CopyTo((Material)mat, cloneTextures); } else if (mat is NotLoaded) { NotLoaded notLoaded = (NotLoaded)mat; if (notLoaded.replacement != null) { mat = notLoaded.replacement; } else { mat = file.LoadComponent(file.SourceStream, notLoaded); } } return (Material)mat; }
public Mesh Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Mesh); Mesh mesh = new Mesh(file); using (MemoryStream mem = new MemoryStream()) { WriteTo(mem); mem.Position = 0; mesh.LoadFrom(mem); } return mesh; }
public TextAsset Clone(AssetCabinet file) { Component text = file.Components.Find ( delegate(Component asset) { return asset.classID1 == UnityClassID.TextAsset && (asset is NotLoaded ? ((NotLoaded)asset).Name : ((TextAsset)asset).m_Name) == m_Name; } ); if (text == null) { file.MergeTypeDefinition(this.file, UnityClassID.TextAsset); TextAsset dest = new TextAsset(file); using (MemoryStream mem = new MemoryStream()) { this.WriteTo(mem); mem.Position = 0; dest.LoadFrom(mem); } return dest; } else if (text is NotLoaded) { NotLoaded notLoaded = (NotLoaded)text; text = file.LoadComponent(file.SourceStream, notLoaded); } return (TextAsset)text; }
public Sprite Clone(AssetCabinet file) { Component sprite = file.Bundle.FindComponent(m_Name, UnityClassID.Sprite); if (sprite == null) { if (m_RD.texture.instance == null) { throw new Exception("Cant clone textureless Sprite"); } file.MergeTypeDefinition(this.file, UnityClassID.Sprite); Sprite dest = new Sprite(file); dest.m_Name = m_Name; dest.m_Rect = m_Rect.Clone(); dest.m_Offset = m_Offset; dest.m_Border = m_Border; dest.m_PixelsToUnits = m_PixelsToUnits; dest.m_Extrude = m_Extrude; dest.m_RD = m_RD.Clone(file); file.Bundle.UnregisterFromUpdate(dest.m_RD.texture.instance); file.Bundle.AppendComponent(m_RD.texture.instance.m_Name, UnityClassID.Texture2D, dest); file.Bundle.RegisterForUpdate(dest); return dest; } else if (sprite is NotLoaded) { NotLoaded notLoaded = (NotLoaded)sprite; if (notLoaded.replacement != null) { sprite = notLoaded.replacement; } else { sprite = file.LoadComponent(file.SourceStream, notLoaded); } } return (Sprite)sprite; }
public Light Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.Light); Light dest = new Light(file); dest.m_Enabled = m_Enabled; dest.m_Type = m_Type; dest.m_Color = m_Color; dest.m_Intensity = m_Intensity; dest.m_Range = m_Range; dest.m_SpotAngle = m_SpotAngle; dest.m_CookieSize = m_CookieSize; using (MemoryStream mem = new MemoryStream()) { m_Shadows.WriteTo(mem); mem.Position = 0; dest.m_Shadows = new ShadowSettings(mem); } Texture2D tex = null; if (m_Cookie.instance != null) { tex = (Texture2D)dest.file.Bundle.FindComponent(m_Cookie.instance.m_Name, UnityClassID.Texture2D); if (tex == null) { tex = m_Cookie.instance.Clone(dest.file); } } dest.m_Cookie = new PPtr<Texture2D>(tex); dest.m_DrawHalo = m_DrawHalo; dest.m_ActuallyLightmapped = m_ActuallyLightmapped; Flare flare = null; if (m_Flare.instance != null) { Report.ReportLog("Flare not cloned"); } dest.m_Flare = new PPtr<Flare>(flare); dest.m_RenderMode = m_RenderMode; using (MemoryStream mem = new MemoryStream()) { m_CullingMask.WriteTo(mem); mem.Position = 0; dest.m_CullingMask = new BitField(mem); } dest.m_Lightmapping = m_Lightmapping; return dest; }
public MeshRenderer Clone(AssetCabinet file) { file.MergeTypeDefinition(this.file, UnityClassID.MeshRenderer); MeshRenderer meshR = new MeshRenderer(file); AssetCabinet.IncompleteClones.Add(new Tuple<Component, Component>(this, meshR)); return meshR; }
public Animator Clone(AssetCabinet file) { Component gameObj = file.Bundle.FindComponent(m_GameObject.instance.m_Name, UnityClassID.GameObject); if (gameObj == null) { file.MergeTypeDefinition(this.file, UnityClassID.Animator); Animator dest = new Animator(file); AssetCabinet.IncompleteClones.Add(new Tuple<Component, Component>(this, dest)); return dest; } else if (gameObj is NotLoaded) { NotLoaded notLoaded = (NotLoaded)gameObj; if (notLoaded.replacement != null) { gameObj = notLoaded.replacement; } else { gameObj = file.LoadComponent(file.SourceStream, notLoaded); } } return ((GameObject)gameObj).FindLinkedComponent(UnityClassID.Animator); }
public Texture2D Clone(AssetCabinet file) { Component tex = file.Bundle != null ? file.Bundle.FindComponent(m_Name, UnityClassID.Texture2D) : file.Parser.GetTexture(m_Name); if (tex == null) { file.MergeTypeDefinition(this.file, UnityClassID.Texture2D); tex = new Texture2D(file); if (file.Bundle != null) { file.Bundle.AddComponent(m_Name, tex); } CopyAttributesTo((Texture2D)tex); CopyImageTo((Texture2D)tex); } else if (tex is NotLoaded) { NotLoaded notLoaded = (NotLoaded)tex; if (notLoaded.replacement != null) { tex = notLoaded.replacement; } else { tex = file.LoadComponent(file.SourceStream, notLoaded); } } return (Texture2D)tex; }
public AssetBundle Clone(AssetCabinet file) { if (file.Bundle != null) { return file.Bundle; } file.MergeTypeDefinition(this.file, UnityClassID.AssetBundle); AssetBundle clone = new AssetBundle(file); clone.pathID = pathID; clone.m_Name = m_Name; clone.m_PreloadTable = new List<PPtr<Object>>(m_PreloadTable.Count); clone.m_PreloadTable.AddRange(m_PreloadTable); clone.m_Container = new List<KeyValuePair<string, AssetInfo>>(file.Components.Count); for (int i = 0; i < m_Container.Count; i++) { var containerEntry = m_Container[i]; bool keepKey = true; int endIdx = containerEntry.Value.preloadIndex + containerEntry.Value.preloadSize; for (int j = containerEntry.Value.preloadIndex; j < endIdx; j++) { if (((NotLoaded)containerEntry.Value.asset.asset).replacement == null) { keepKey = false; break; } } do { if (keepKey) { clone.m_Container.Add(m_Container[i]); } } while (++i < m_Container.Count && containerEntry.Key == m_Container[i].Key); } clone.m_MainAsset = new AssetInfo(file); clone.m_MainAsset.asset = new PPtr<Object>((Component)null); clone.m_ScriptCompatibility = (AssetBundleScriptInfo[])m_ScriptCompatibility.Clone(); clone.m_ClassCompatibility = (KeyValuePair<int, uint>[])m_ClassCompatibility.Clone(); clone.m_RuntimeCompatibility = m_RuntimeCompatibility; return clone; }