public dynamic LoadComponent(Stream stream, int index, NotLoaded comp) { stream.Position = comp.offset; try { switch (comp.classID1) { case UnityClassID.AnimationClip: { AnimationClip animationClip = new AnimationClip(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, animationClip, comp); animationClip.LoadFrom(stream); return(animationClip); } case UnityClassID.Animator: { Animator animator = new Animator(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, animator, comp); animator.LoadFrom(stream); return(animator); } case UnityClassID.AnimatorController: { AnimatorController animatorController = new AnimatorController(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, animatorController, comp); animatorController.LoadFrom(stream); return(animatorController); } case UnityClassID.AssetBundle: { AssetBundle assetBundle = new AssetBundle(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, assetBundle, comp); assetBundle.LoadFrom(stream); return(assetBundle); } case UnityClassID.AudioClip: { if (loadingReferencials) { return(comp); } AudioClip ac = new AudioClip(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, ac, comp); ac.LoadFrom(stream); return(ac); } case UnityClassID.AudioListener: { AudioListener audioListener = new AudioListener(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, audioListener, comp); audioListener.LoadFrom(stream); return(audioListener); } case UnityClassID.AudioSource: { AudioSource audioSrc = new AudioSource(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, audioSrc, comp); audioSrc.LoadFrom(stream); return(audioSrc); } case UnityClassID.Avatar: { if (loadingReferencials) { return(comp); } Avatar avatar = new Avatar(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, avatar, comp); avatar.LoadFrom(stream); return(avatar); } case UnityClassID.BoxCollider: { BoxCollider boxCol = new BoxCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, boxCol, comp); boxCol.LoadFrom(stream); return(boxCol); } case UnityClassID.Camera: { Camera camera = new Camera(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, camera, comp); camera.LoadFrom(stream); return(camera); } case UnityClassID.CapsuleCollider: { CapsuleCollider capsuleCol = new CapsuleCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, capsuleCol, comp); capsuleCol.LoadFrom(stream); return(capsuleCol); } case UnityClassID.Cubemap: { Cubemap cubemap = new Cubemap(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, cubemap, comp); cubemap.LoadFrom(stream); Parser.Textures.Add(cubemap); return(cubemap); } case UnityClassID.EllipsoidParticleEmitter: { EllipsoidParticleEmitter ellipsoid = new EllipsoidParticleEmitter(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, ellipsoid, comp); ellipsoid.LoadFrom(stream); return(ellipsoid); } case UnityClassID.FlareLayer: { FlareLayer flareLayer = new FlareLayer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, flareLayer, comp); flareLayer.LoadFrom(stream); return(flareLayer); } case UnityClassID.Light: { Light light = new Light(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, light, comp); light.LoadFrom(stream); return(light); } case UnityClassID.LinkToGameObject: { LinkToGameObject link = new LinkToGameObject(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, link, comp); link.LoadFrom(stream); return(link); } case UnityClassID.LinkToGameObject223: { LinkToGameObject223 link = new LinkToGameObject223(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, link, comp); link.LoadFrom(stream); return(link); } case UnityClassID.LinkToGameObject225: { LinkToGameObject225 link = new LinkToGameObject225(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, link, comp); link.LoadFrom(stream); return(link); } case UnityClassID.GameObject: { GameObject gameObj = new GameObject(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, gameObj, comp); gameObj.LoadFrom(stream); return(gameObj); } case UnityClassID.Material: { Material mat = new Material(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, mat, comp); mat.LoadFrom(stream); return(mat); } case UnityClassID.Mesh: { if (loadingReferencials) { return(comp); } Mesh mesh = new Mesh(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, mesh, comp); mesh.LoadFrom(stream); return(mesh); } case UnityClassID.MeshCollider: { MeshCollider meshCol = new MeshCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, meshCol, comp); meshCol.LoadFrom(stream); return(meshCol); } case UnityClassID.MeshFilter: { MeshFilter meshFilter = new MeshFilter(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, meshFilter, comp); meshFilter.LoadFrom(stream); return(meshFilter); } case UnityClassID.MeshRenderer: { MeshRenderer meshRenderer = new MeshRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, meshRenderer, comp); meshRenderer.LoadFrom(stream); return(meshRenderer); } default: if (comp.classID2 == UnityClassID.MonoBehaviour) { if (Types.Count > 0) { MonoBehaviour monoBehaviour = new MonoBehaviour(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, monoBehaviour, comp); monoBehaviour.LoadFrom(stream); return(monoBehaviour); } else { string message = comp.classID2 + " unhandled because of absence of Types in Cabinet (*.assets)"; if (!reported.Contains(message)) { Report.ReportLog(message); reported.Add(message); } return(comp); } } else { string message = "Unhandled class: " + comp.classID1 + "/" + comp.classID2; if (!reported.Contains(message)) { Report.ReportLog(message); reported.Add(message); } } break; case UnityClassID.MonoScript: { if (loadingReferencials) { return(comp); } MonoScript monoScript = new MonoScript(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, monoScript, comp); monoScript.LoadFrom(stream); return(monoScript); } case UnityClassID.MultiLink: { MultiLink multi = new MultiLink(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, multi, comp); multi.LoadFrom(stream); return(multi); } case UnityClassID.ParticleAnimator: { ParticleAnimator particleAnimator = new ParticleAnimator(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleAnimator, comp); particleAnimator.LoadFrom(stream); return(particleAnimator); } case UnityClassID.ParticleRenderer: { ParticleRenderer particleRenderer = new ParticleRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleRenderer, comp); particleRenderer.LoadFrom(stream); return(particleRenderer); } case UnityClassID.ParticleSystem: { ParticleSystem particleSystem = new ParticleSystem(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleSystem, comp); particleSystem.LoadFrom(stream); return(particleSystem); } case UnityClassID.ParticleSystemRenderer: { ParticleSystemRenderer particleSystemRenderer = new ParticleSystemRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleSystemRenderer, comp); particleSystemRenderer.LoadFrom(stream); return(particleSystemRenderer); } case UnityClassID.Projector: { Projector projector = new Projector(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, projector, comp); projector.LoadFrom(stream); return(projector); } case UnityClassID.Rigidbody: { RigidBody rigidBody = new RigidBody(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, rigidBody, comp); rigidBody.LoadFrom(stream); return(rigidBody); } case UnityClassID.Shader: { Shader shader = new Shader(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, shader, comp); shader.LoadFrom(stream); return(shader); } case UnityClassID.SkinnedMeshRenderer: { SkinnedMeshRenderer sMesh = new SkinnedMeshRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, sMesh, comp); sMesh.LoadFrom(stream); return(sMesh); } case UnityClassID.SphereCollider: { SphereCollider sphereCol = new SphereCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, sphereCol, comp); sphereCol.LoadFrom(stream); return(sphereCol); } case UnityClassID.Sprite: { Sprite sprite = new Sprite(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, sprite, comp); sprite.LoadFrom(stream); return(sprite); } case UnityClassID.SpriteRenderer: { SpriteRenderer spriteRenderer = new SpriteRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, spriteRenderer, comp); spriteRenderer.LoadFrom(stream); return(spriteRenderer); } case UnityClassID.TextAsset: { if (loadingReferencials) { return(comp); } TextAsset ta = new TextAsset(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, ta, comp); ta.LoadFrom(stream); return(ta); } case UnityClassID.Texture2D: { if (loadingReferencials) { return(comp); } Texture2D tex = new Texture2D(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, tex, comp); tex.LoadFrom(stream); Parser.Textures.Add(tex); return(tex); } case UnityClassID.Transform: { Transform trans = new Transform(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, trans, comp); trans.LoadFrom(stream); return(trans); } } } catch { Report.ReportLog("Failed to load " + comp.classID1 + "/" + comp.classID2 + " PathID=" + comp.pathID); foreach (NotLoaded notLoaded in RemovedList) { if (notLoaded == comp) { RemovedList.Remove(notLoaded); Components.RemoveAt(index); notLoaded.replacement = null; Components.Insert(index, notLoaded); break; } } } return(null); }
public dynamic LoadComponent(Stream stream, int index, NotLoaded comp) { stream.Position = comp.offset; try { switch (comp.classID1) { case UnityClassID.AnimationClip: { AnimationClip animationClip = new AnimationClip(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, animationClip, comp); animationClip.LoadFrom(stream); return animationClip; } case UnityClassID.Animator: { Animator animator = new Animator(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, animator, comp); animator.LoadFrom(stream); return animator; } case UnityClassID.AnimatorController: { AnimatorController animatorController = new AnimatorController(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, animatorController, comp); animatorController.LoadFrom(stream); return animatorController; } case UnityClassID.AssetBundle: { AssetBundle assetBundle = new AssetBundle(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, assetBundle, comp); assetBundle.LoadFrom(stream); return assetBundle; } case UnityClassID.AudioClip: { if (loadingReferencials) { return comp; } AudioClip ac = new AudioClip(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, ac, comp); ac.LoadFrom(stream); return ac; } case UnityClassID.AudioListener: { AudioListener audioListener = new AudioListener(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, audioListener, comp); audioListener.LoadFrom(stream); return audioListener; } case UnityClassID.AudioSource: { AudioSource audioSrc = new AudioSource(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, audioSrc, comp); audioSrc.LoadFrom(stream); return audioSrc; } case UnityClassID.Avatar: { if (loadingReferencials) { return comp; } Avatar avatar = new Avatar(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, avatar, comp); avatar.LoadFrom(stream); return avatar; } case UnityClassID.BoxCollider: { BoxCollider boxCol = new BoxCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, boxCol, comp); boxCol.LoadFrom(stream); return boxCol; } case UnityClassID.Camera: { Camera camera = new Camera(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, camera, comp); camera.LoadFrom(stream); return camera; } case UnityClassID.CapsuleCollider: { CapsuleCollider capsuleCol = new CapsuleCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, capsuleCol, comp); capsuleCol.LoadFrom(stream); return capsuleCol; } case UnityClassID.Cubemap: { Cubemap cubemap = new Cubemap(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, cubemap, comp); cubemap.LoadFrom(stream); Parser.Textures.Add(cubemap); return cubemap; } case UnityClassID.EllipsoidParticleEmitter: { EllipsoidParticleEmitter ellipsoid = new EllipsoidParticleEmitter(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, ellipsoid, comp); ellipsoid.LoadFrom(stream); return ellipsoid; } case UnityClassID.FlareLayer: { FlareLayer flareLayer = new FlareLayer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, flareLayer, comp); flareLayer.LoadFrom(stream); return flareLayer; } case UnityClassID.Light: { Light light = new Light(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, light, comp); light.LoadFrom(stream); return light; } case UnityClassID.LinkToGameObject: { LinkToGameObject link = new LinkToGameObject(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, link, comp); link.LoadFrom(stream); return link; } case UnityClassID.LinkToGameObject223: { LinkToGameObject223 link = new LinkToGameObject223(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, link, comp); link.LoadFrom(stream); return link; } case UnityClassID.LinkToGameObject225: { LinkToGameObject225 link = new LinkToGameObject225(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, link, comp); link.LoadFrom(stream); return link; } case UnityClassID.GameObject: { GameObject gameObj = new GameObject(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, gameObj, comp); gameObj.LoadFrom(stream); return gameObj; } case UnityClassID.Material: { Material mat = new Material(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, mat, comp); mat.LoadFrom(stream); return mat; } case UnityClassID.Mesh: { if (loadingReferencials) { return comp; } Mesh mesh = new Mesh(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, mesh, comp); mesh.LoadFrom(stream); return mesh; } case UnityClassID.MeshCollider: { MeshCollider meshCol = new MeshCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, meshCol, comp); meshCol.LoadFrom(stream); return meshCol; } case UnityClassID.MeshFilter: { MeshFilter meshFilter = new MeshFilter(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, meshFilter, comp); meshFilter.LoadFrom(stream); return meshFilter; } case UnityClassID.MeshRenderer: { MeshRenderer meshRenderer = new MeshRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, meshRenderer, comp); meshRenderer.LoadFrom(stream); return meshRenderer; } default: if (comp.classID2 == UnityClassID.MonoBehaviour) { if (Types.Count > 0) { MonoBehaviour monoBehaviour = new MonoBehaviour(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, monoBehaviour, comp); monoBehaviour.LoadFrom(stream); return monoBehaviour; } else { string message = comp.classID2 + " unhandled because of absence of Types in Cabinet (*.assets)"; if (!reported.Contains(message)) { Report.ReportLog(message); reported.Add(message); } return comp; } } else { string message = "Unhandled class: " + comp.classID1 + "/" + comp.classID2; if (!reported.Contains(message)) { Report.ReportLog(message); reported.Add(message); } } break; case UnityClassID.MonoScript: { if (loadingReferencials) { return comp; } MonoScript monoScript = new MonoScript(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, monoScript, comp); monoScript.LoadFrom(stream); return monoScript; } case UnityClassID.MultiLink: { MultiLink multi = new MultiLink(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, multi, comp); multi.LoadFrom(stream); return multi; } case UnityClassID.ParticleAnimator: { ParticleAnimator particleAnimator = new ParticleAnimator(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleAnimator, comp); particleAnimator.LoadFrom(stream); return particleAnimator; } case UnityClassID.ParticleRenderer: { ParticleRenderer particleRenderer = new ParticleRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleRenderer, comp); particleRenderer.LoadFrom(stream); return particleRenderer; } case UnityClassID.ParticleSystem: { ParticleSystem particleSystem = new ParticleSystem(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleSystem, comp); particleSystem.LoadFrom(stream); return particleSystem; } case UnityClassID.ParticleSystemRenderer: { ParticleSystemRenderer particleSystemRenderer = new ParticleSystemRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, particleSystemRenderer, comp); particleSystemRenderer.LoadFrom(stream); return particleSystemRenderer; } case UnityClassID.Projector: { Projector projector = new Projector(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, projector, comp); projector.LoadFrom(stream); return projector; } case UnityClassID.Rigidbody: { RigidBody rigidBody = new RigidBody(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, rigidBody, comp); rigidBody.LoadFrom(stream); return rigidBody; } case UnityClassID.Shader: { Shader shader = new Shader(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, shader, comp); shader.LoadFrom(stream); return shader; } case UnityClassID.SkinnedMeshRenderer: { SkinnedMeshRenderer sMesh = new SkinnedMeshRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, sMesh, comp); sMesh.LoadFrom(stream); return sMesh; } case UnityClassID.SphereCollider: { SphereCollider sphereCol = new SphereCollider(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, sphereCol, comp); sphereCol.LoadFrom(stream); return sphereCol; } case UnityClassID.Sprite: { Sprite sprite = new Sprite(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, sprite, comp); sprite.LoadFrom(stream); return sprite; } case UnityClassID.SpriteRenderer: { SpriteRenderer spriteRenderer = new SpriteRenderer(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, spriteRenderer, comp); spriteRenderer.LoadFrom(stream); return spriteRenderer; } case UnityClassID.TextAsset: { if (loadingReferencials) { return comp; } TextAsset ta = new TextAsset(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, ta, comp); ta.LoadFrom(stream); return ta; } case UnityClassID.Texture2D: { if (loadingReferencials) { return comp; } Texture2D tex = new Texture2D(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, tex, comp); tex.LoadFrom(stream); Parser.Textures.Add(tex); return tex; } case UnityClassID.Transform: { Transform trans = new Transform(this, comp.pathID, comp.classID1, comp.classID2); ReplaceSubfile(index, trans, comp); trans.LoadFrom(stream); return trans; } } } catch { Report.ReportLog("Failed to load " + comp.classID1 + "/" + comp.classID2 + " PathID=" + comp.pathID); foreach (NotLoaded notLoaded in RemovedList) { if (notLoaded == comp) { RemovedList.Remove(notLoaded); Components.RemoveAt(index); notLoaded.replacement = null; Components.Insert(index, notLoaded); break; } } } return null; }
public UnityConverter(UnityParser parser, List<MeshRenderer> sMeshes, bool skins) { foreach (SkinnedMeshRenderer sMesh in sMeshes) { Transform rootBone = sMesh.m_RootBone.instance; if (rootBone != null) { while (rootBone.Parent != null) { rootBone = rootBone.Parent; } if (FrameList == null) { ConvertFrames(rootBone, null); } else if (FrameList[0].Name != rootBone.m_GameObject.instance.m_Name) { FrameList[0].Name = "Joined_Root"; } } } if (skins) { foreach (Component asset in parser.Cabinet.Components) { if (asset.classID1 == UnityClassID.Avatar) { avatar = parser.Cabinet.LoadComponent(asset.pathID); break; } } } ConvertMeshRenderers(sMeshes, skins, false); AnimationList = new List<ImportedAnimation>(); }
public UnityConverter(Animator animator, List<MeshRenderer> meshList, bool skins, bool morphs) { ConvertFrames(animator.RootTransform, null); if (skins) { avatar = animator.m_Avatar.instance; } ConvertMeshRenderers(meshList, skins, morphs); AnimationList = new List<ImportedAnimation>(); }
private void viewDataToolStripMenuItem_Click(object sender, EventArgs e) { try { ListView subfilesList = null; if (tabControlAssets.SelectedTab == tabPageAnimators) { subfilesList = animatorsList; } else if (tabControlAssets.SelectedTab == tabPageMaterials) { subfilesList = materialsList; } else if (tabControlAssets.SelectedTab == tabPageOthers) { subfilesList = othersList; } if (subfilesList != null) { string[] srt = new string[4] { null, "Translation", "Rotation", "Scaling" }; char[] axis = new char[4] { 'X', 'Y', 'Z', 'W' }; foreach (ListViewItem item in subfilesList.SelectedItems) { Component asset = (Component)item.Tag; if (asset.classID2 != UnityClassID.MonoBehaviour && asset is NotLoaded) { asset = Editor.Parser.Cabinet.LoadComponent(asset.pathID); item.Tag = asset; } switch (asset.classID2) { #if DEBUG case UnityClassID.AnimationClip: AnimationClip clip = (AnimationClip)asset; string msg = clip.m_Name + " type=" + clip.m_AnimationType + " compressed=" + clip.m_Compressed + " useHighQ=" + clip.m_UseHighQualityCurve; msg += (clip.m_RotationCurves.Count > 0 ? " rotC=" + clip.m_RotationCurves.Count : "") + (clip.m_CompressedRotationCurves.Count > 0 ? " compRotC=" + clip.m_CompressedRotationCurves.Count : "") + (clip.m_PositionCurves.Count > 0 ? " posC=" + clip.m_PositionCurves.Count : "") + (clip.m_ScaleCurves.Count > 0 ? " scaleC=" + clip.m_ScaleCurves.Count : "") + (clip.m_FloatCurves.Count > 0 ? " floatC=" + clip.m_FloatCurves.Count : "") + (clip.m_PPtrCurves.Count > 0 ? " ptrC=" + clip.m_PPtrCurves.Count : ""); msg += "\r\n sampleR=" + clip.m_SampleRate + " wrapM=" + clip.m_WrapMode; msg += " muscleCSz=" + clip.m_MuscleClipSize + " AvgSpd=" + clip.m_MuscleClip.m_AverageSpeed + " StartT=" + clip.m_MuscleClip.m_StartTime + " StopT=" + clip.m_MuscleClip.m_StopTime + " AvgAngSpd=" + clip.m_MuscleClip.m_AverageAngularSpeed + (clip.m_MuscleClip.m_Clip.m_Binding.m_ValueArray.Count > 0 ? " bindVal=" + clip.m_MuscleClip.m_Clip.m_Binding.m_ValueArray.Count : "") + (clip.m_MuscleClip.m_Clip.m_ConstantClip.data.Length > 0 ? "\r\n constC=" + clip.m_MuscleClip.m_Clip.m_ConstantClip.data.Length : "") + "\r\n Sampl=(" + (clip.m_MuscleClip.m_Clip.m_DenseClip.m_SampleArray.Length > 0 ? "len=" + clip.m_MuscleClip.m_Clip.m_DenseClip.m_SampleArray.Length : "") + ", frames=" + clip.m_MuscleClip.m_Clip.m_DenseClip.m_FrameCount + ", curves=" + clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount + ", sampleR=" + clip.m_MuscleClip.m_Clip.m_DenseClip.m_SampleRate + ", beginT=" + clip.m_MuscleClip.m_Clip.m_DenseClip.m_BeginTime + ")" + (clip.m_MuscleClip.m_Clip.m_StreamedClip.data.Length > 0 ? "\r\n streamedC=" + clip.m_MuscleClip.m_Clip.m_StreamedClip.data.Length + ", curves=" + clip.m_MuscleClip.m_Clip.m_StreamedClip.curveCount : ""); msg += (clip.m_MuscleClip.m_DeltaPose.m_DoFArray.Length > 0 ? "\r\n deltaPosDOF=" + clip.m_MuscleClip.m_DeltaPose.m_DoFArray.Length : "") + (clip.m_MuscleClip.m_DeltaPose.m_GoalArray.Count > 0 ? " deltaPosGoals=" + clip.m_MuscleClip.m_DeltaPose.m_GoalArray.Count : "") + (clip.m_MuscleClip.m_DeltaPose.m_LeftHandPose.m_DoFArray.Length > 0 ? " leftHandDOF=" + clip.m_MuscleClip.m_DeltaPose.m_LeftHandPose.m_DoFArray.Length : "") + (clip.m_MuscleClip.m_DeltaPose.m_RightHandPose.m_DoFArray.Length > 0 ? " rightHandDOF=" + clip.m_MuscleClip.m_DeltaPose.m_RightHandPose.m_DoFArray.Length : "") + (clip.m_MuscleClip.m_IndexArray.Length > 0 ? " Indices=" + clip.m_MuscleClip.m_IndexArray.Length : "") + (clip.m_MuscleClip.m_ValueArrayDelta.Count > 0 ? " valADelta=" + clip.m_MuscleClip.m_ValueArrayDelta.Count : ""); int[] a = new int[6]; int b = -1; int c = -1; uint[] d = new uint[6]; HashSet<uint> distinctConst = new HashSet<uint>(); HashSet<uint> distinctVariable = new HashSet<uint>(); foreach (var binding in clip.m_ClipBindingConstant.genericBindings) { //msg += "\r\n" + lastAvatar.FindBoneName(binding.path) + " " + binding.attribute; if (binding.attribute != b) { c++; b = (int)binding.attribute; d[c] = binding.attribute; } a[c]++; if (c >= 3) { distinctConst.Add(binding.path); } else { distinctVariable.Add(binding.path); } } msg += "\r\n Variable att(" + d[0] + ":" + a[0] + ", " + d[1] + ":" + a[1] + ", " + d[2] + ":" + a[2] + ") distinct=" + distinctVariable.Count + ", Const att(" + d[3] + ":" + a[3] + ", " + d[4] + ":" + a[4] + ", " + d[5] + ":" + a[5] + ") distinct=" + distinctConst.Count; msg += (clip.m_Events.Count > 0 ? " events=" + clip.m_Events.Count : ""); if (clip.m_MuscleClip.m_Clip.m_DenseClip.m_SampleArray.Length > 0) { msg += "\r\n\r\nDense Clip Sampled Data:"; for (int frameIdx = 0; frameIdx < clip.m_MuscleClip.m_Clip.m_DenseClip.m_FrameCount; frameIdx++) { if (frameIdx >= 4 && frameIdx < clip.m_MuscleClip.m_Clip.m_DenseClip.m_FrameCount - 1) { if (frameIdx == 4) { msg += "\r\n ..."; } continue; } msg += "\r\n" + frameIdx; int translations = 0, scalings = 0, sampleIdx = 0; int skipRotations = d[0] == 2 ? a[0] * 4 : 0; for (int curveIdx = 0; curveIdx < clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount; ) { GenericBinding binding = StreamedClip.StreamedKeyPart.FindBinding(skipRotations + curveIdx, clip.m_ClipBindingConstant.genericBindings); int numCoords = binding.attribute == 1 || binding.attribute == 3 ? 3 : 4; string trackName = lastAvatar.FindBoneName(binding.path); if (trackName == null) { msg += " binding doesn't match avatar"; frameIdx = clip.m_MuscleClip.m_Clip.m_DenseClip.m_FrameCount; break; } if (trackName.Equals("cf_J_Shoulder_L") || binding.attribute == 1 && ++translations <= 2 || binding.attribute == 3 && ++scalings <= 2) { for (int j = 0; j < numCoords; j++) { msg += "\r\n " + curveIdx + ": value=" + clip.m_MuscleClip.m_Clip.m_DenseClip.m_SampleArray[frameIdx * clip.m_MuscleClip.m_Clip.m_DenseClip.m_CurveCount + sampleIdx] + " (" + trackName + ":" + srt[binding.attribute] + "-" + axis[j] + ")"; sampleIdx++; curveIdx++; } } else { sampleIdx += numCoords; curveIdx += numCoords; } } } } if (clip.m_MuscleClip.m_Clip.m_StreamedClip.data.Length > 0) { msg += "\r\n\r\nStreamed Clip Data:"; List<StreamedClip.StreamedFrame> frameList = clip.m_MuscleClip.m_Clip.m_StreamedClip.ReadData(); float minX = Single.MaxValue, maxX = Single.MinValue, minY = Single.MaxValue, maxY = Single.MinValue, minZ = Single.MaxValue, maxZ = Single.MinValue; for (int frameIdx = 0; frameIdx < frameList.Count; frameIdx++) { /*if (frameIdx >= 10 && frameIdx < frameList.Count - 10) { if (frameIdx == 10) { msg += "\r\n... ... ..."; } continue; }*/ StreamedClip.StreamedFrame frame = frameList[frameIdx]; if (frameIdx < 7 || frameIdx >= frameList.Count - 7) { msg += "\r\n" + frameIdx + ": time=" + frame.time + (frameIdx + 1 < frameList.Count ? ", dt=" + (frameList[frameIdx + 1].time - frame.time) : "") + " curves=" + frame.keyList.Count; } else if (frameIdx == 7) { msg += "\r\n ... ... ..."; } /*if (frameIdx >= 7 && frameIdx < frameList.Count - 7) { msg += " ..."; continue; }*/ int translations = 0, scalings = 0; for (int keyIndex = 0; keyIndex < frame.keyList.Count; ) { StreamedClip.StreamedKeyPart key = frame.keyList[keyIndex]; GenericBinding binding = StreamedClip.StreamedKeyPart.FindBinding(key.index, clip.m_ClipBindingConstant.genericBindings); int numParts = binding.attribute == 1 || binding.attribute == 3 ? 3 : 4; string trackName = lastAvatar.FindBoneName(binding.path); if (trackName == null) { msg += " binding doesn't match avatar"; frameIdx = frameList.Count; break; } //if (trackName.Equals("cf_J_Shoulder_L") || binding.attribute == 1 && ++translations <= 3 || binding.attribute == 3 && ++scalings <= 3) { for (int j = 0; j < numParts; j++, keyIndex++) { key = frame.keyList[keyIndex]; if ((frameIdx < 7 || frameIdx >= frameList.Count - 7) && (trackName.Equals("cf_J_Shoulder_L") || binding.attribute == 1 && ++translations <= 3 || binding.attribute == 3 && ++scalings <= 3)) { msg += "\r\n " + key.index + " (" + trackName + ":" + srt[binding.attribute] + "-" + axis[j] + ")" + ": tangent info=" + key.tcb + " value=" + key.value; } if (key.tcb.X < minX) minX = key.tcb.X; if (key.tcb.X > maxX) maxX = key.tcb.X; if (key.tcb.Y < minY) minY = key.tcb.Y; if (key.tcb.Y > maxY) maxY = key.tcb.Y; if (key.tcb.Z < minZ) minZ = key.tcb.Z; if (key.tcb.Z > maxZ) maxZ = key.tcb.Z; } } /*else { keyIndex += numParts; }*/ } } msg += "\r\nminX=" + minX + " maxX=" + maxX + " minY=" + minY + " maxY=" + maxY + " minZ=" + minZ + " maxZ=" + maxZ; } Report.ReportLog(msg); break; case UnityClassID.AnimatorController: AnimatorController animController = (AnimatorController)asset; msg = animController.m_Name + (animController.m_Controller.m_LayerArray.Length > 0 ? " layers= Body0=" + animController.m_Controller.m_LayerArray[0].m_BodyMask.word0.ToString("X8") + ",1=" + animController.m_Controller.m_LayerArray[0].m_BodyMask.word1.ToString("X8") + ", skMasks=" + animController.m_Controller.m_LayerArray.Length + ", skMask[0]Len=" + animController.m_Controller.m_LayerArray[0].m_SkeletonMask.m_Data.Length : "") + (animController.m_Controller.m_StateMachineArray.Length > 0 ? " states=" + animController.m_Controller.m_StateMachineArray.Length + " const=" + animController.m_Controller.m_StateMachineArray[0].m_StateConstantArray.Length + ", any=" + animController.m_Controller.m_StateMachineArray[0].m_AnyStateTransitionConstantArray.Length : "") + (animController.m_Controller.m_Values.m_ValueArray.Count > 0 ? " values=" + animController.m_Controller.m_Values.m_ValueArray.Count : "") + (animController.m_Controller.m_DefaultValues.m_BoolValues.Length > 0 ? " defBool=" + animController.m_Controller.m_DefaultValues.m_BoolValues.Length : "") + (animController.m_Controller.m_DefaultValues.m_IntValues.Length > 0 ? " defInt=" + animController.m_Controller.m_DefaultValues.m_IntValues.Length : "") + (animController.m_Controller.m_DefaultValues.m_FloatValues.Length > 0 ? " defFloat=" + animController.m_Controller.m_DefaultValues.m_FloatValues.Length : "") + (animController.m_Controller.m_DefaultValues.m_PositionValues.Length > 0 ? " defPos=" + animController.m_Controller.m_DefaultValues.m_PositionValues.Length : "") + (animController.m_Controller.m_DefaultValues.m_QuaternionValues.Length > 0 ? " defRot=" + animController.m_Controller.m_DefaultValues.m_QuaternionValues.Length : "") + (animController.m_Controller.m_DefaultValues.m_ScaleValues.Length > 0 ? " defScale=" + animController.m_Controller.m_DefaultValues.m_ScaleValues.Length : "") + " clips=" + animController.m_AnimationClips.Count; /*foreach (var pair in animController.m_TOS) { msg += "\r\n " + pair.Key + " " + pair.Value; }*/ // clip names for (int i = 0; i < animController.m_Controller.m_StateMachineArray[0].m_StateConstantArray.Length; i++) { StateConstant sConst = animController.m_Controller.m_StateMachineArray[0].m_StateConstantArray[i]; uint clipHash = sConst.m_LeafInfoArray[0].m_IDArray[0]; string clipName = null; foreach (var pair in animController.m_TOS) { if (pair.Key == clipHash) { clipName = pair.Value; break; } } msg += "\r\n" + i + ": transC=" + sConst.m_TransitionConstantArray.Length + " blends=" + sConst.m_BlendTreeConstantIndexArray.Length + " blendIdx[0]=" + sConst.m_BlendTreeConstantIndexArray[0] + ", leaves=" + sConst.m_LeafInfoArray.Length + " leaveID[0]=" + clipName + "/clip=" + (animController.m_AnimationClips[i].instance.m_Name) + ", blends=" + sConst.m_BlendTreeConstantArray.Length + " nodes=" + sConst.m_BlendTreeConstantArray[0].m_NodeArray.Length + " blendTreeNode0chlds=" + sConst.m_BlendTreeConstantArray[0].m_NodeArray[0].m_ChildIndices.Length; } Report.ReportLog(msg); break; case UnityClassID.Animator: lastAvatar = ((Animator)asset).m_Avatar.instance; AnimatorEditor aEditor = new AnimatorEditor((Animator)asset); msg = "Frames=" + aEditor.Frames.Count + " AvTOS=" + lastAvatar.m_TOS.Count + " AskX=" + lastAvatar.m_Avatar.m_AvatarSkeletonPose.m_X.Count + " DpX=" + lastAvatar.m_Avatar.m_DefaultPose.m_X.Count + " RmspX=" + lastAvatar.m_Avatar.m_RootMotionSkeletonPose.m_X.Count + " HspX=" + lastAvatar.m_Avatar.m_Human.m_SkeletonPose.m_X.Count + " Sk1=" + lastAvatar.m_Avatar.m_AvatarSkeleton.m_Node.Count + "," + lastAvatar.m_Avatar.m_AvatarSkeleton.m_ID.Count + "," + lastAvatar.m_Avatar.m_AvatarSkeleton.m_AxesArray.Count + " Sk2=" + lastAvatar.m_Avatar.m_RootMotionSkeleton.m_Node.Count + "," + lastAvatar.m_Avatar.m_RootMotionSkeleton.m_ID.Count + "," + lastAvatar.m_Avatar.m_RootMotionSkeleton.m_AxesArray.Count + " Sk3=" + lastAvatar.m_Avatar.m_Human.m_Skeleton.m_Node.Count + "," + lastAvatar.m_Avatar.m_Human.m_Skeleton.m_ID.Count + "," + lastAvatar.m_Avatar.m_Human.m_Skeleton.m_AxesArray.Count; foreach (var pair in lastAvatar.m_TOS) { msg += "\r\n " + pair.Key + " " + pair.Value; } Report.ReportLog(msg); break; #endif case UnityClassID.MonoBehaviour: case UnityClassID.MonoScript: case UnityClassID.Material: case UnityClassID.Shader: Gui.Scripting.RunScript(EditorVar + ".ViewAssetData(pathID=" + asset.pathID + ")"); break; } } } } catch (Exception ex) { Utility.ReportException(ex); } }
public void PasteAllMarked() { int components = Parser.Cabinet.Components.Count; try { Parser.Cabinet.BeginLoadingSkippedComponents(); foreach (object obj in Gui.Scripting.Variables.Values) { if (obj is Unity3dEditor && (Unity3dEditor)obj != this) { Unity3dEditor editor = (Unity3dEditor)obj; HashSet <Component> remove = new HashSet <Component>(); HashSet <Component> replace = new HashSet <Component>(); foreach (Component asset in editor.Marked) { Component loaded; if (asset is NotLoaded) { loaded = editor.Parser.Cabinet.LoadComponent(asset.pathID); remove.Add(asset); replace.Add(loaded); } else { loaded = asset; } switch (asset.classID2) { case UnityClassID.Texture2D: Texture2D tex = (Texture2D)loaded; tex.Clone(Parser.Cabinet); break; case UnityClassID.Cubemap: Cubemap cubemap = (Cubemap)loaded; cubemap.Clone(Parser.Cabinet); break; case UnityClassID.Material: Material mat = (Material)loaded; mat.Clone(Parser.Cabinet); break; case UnityClassID.Mesh: Mesh mesh = (Mesh)loaded; mesh.Clone(Parser.Cabinet); break; case UnityClassID.Shader: Shader shader = (Shader)loaded; shader.Clone(Parser.Cabinet); break; case UnityClassID.Sprite: Sprite sprite = (Sprite)loaded; sprite.Clone(Parser.Cabinet); break; case UnityClassID.Animator: Parser.Cabinet.MergeTypeDefinition(loaded.file, UnityClassID.GameObject); Parser.Cabinet.MergeTypeDefinition(loaded.file, UnityClassID.Transform); Animator anim = (Animator)loaded; anim.m_GameObject.instance.Clone(Parser.Cabinet); break; case UnityClassID.GameObject: Parser.Cabinet.MergeTypeDefinition(loaded.file, UnityClassID.GameObject); Parser.Cabinet.MergeTypeDefinition(loaded.file, UnityClassID.Transform); GameObject gameObj = (GameObject)loaded; Component clone = gameObj.Clone(Parser.Cabinet); Animator vAnim = new Animator(Parser.Cabinet, 0, 0, 0); vAnim.m_Avatar = new PPtr <Avatar>((Component)null); vAnim.m_GameObject = new PPtr <GameObject>(clone); if (loaded.file.Bundle.numContainerEntries(gameObj.m_Name, UnityClassID.GameObject) > 1) { Report.ReportLog("Warning! Animator " + gameObj.m_Name + " has multiple entries in the AssetBundle's Container."); } vAnim.file.Bundle.AddComponent(vAnim.m_GameObject.instance.m_Name, clone); VirtualAnimators.Add(vAnim); if (loaded != asset) { foreach (Animator a in editor.VirtualAnimators) { if (a.m_GameObject.asset == asset) { a.m_GameObject = new PPtr <GameObject>(loaded); break; } } } break; case UnityClassID.Avatar: Avatar avatar = (Avatar)loaded; avatar.Clone(Parser.Cabinet); break; case UnityClassID.MonoBehaviour: MonoBehaviour monoB = (MonoBehaviour)loaded; monoB.Clone(Parser.Cabinet); break; case UnityClassID.TextAsset: TextAsset text = (TextAsset)loaded; text.Clone(Parser.Cabinet); break; case UnityClassID.AnimationClip: AnimationClip clip = (AnimationClip)loaded; clip.Clone(Parser.Cabinet); break; } } do { HashSet <Tuple <Component, Component> > loopSet = new HashSet <Tuple <Component, Component> >(AssetCabinet.IncompleteClones); AssetCabinet.IncompleteClones.Clear(); foreach (var pair in loopSet) { Component src = pair.Item1; Component dest = pair.Item2; Type t = src.GetType(); MethodInfo info = t.GetMethod("CopyTo", new Type[] { t }); info.Invoke(src, new object[] { dest }); } }while (AssetCabinet.IncompleteClones.Count > 0); foreach (Component asset in remove) { editor.Marked.Remove(asset); } foreach (Component asset in replace) { editor.Marked.Add(asset); } } } } finally { Parser.Cabinet.EndLoadingSkippedComponents(); if (components != Parser.Cabinet.Components.Count) { Changed = true; } } }
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; }