Esempio n. 1
0
        public void CopyTo(MeshRenderer dest)
        {
            dest.m_Enabled = m_Enabled;
            dest.m_CastShadows = m_CastShadows;
            dest.m_ReceiveShadows = m_ReceiveShadows;
            dest.m_LightmapIndex = m_LightmapIndex;
            dest.m_LightmapTilingOffset = m_LightmapTilingOffset;

            dest.m_Materials = new List<PPtr<Material>>(m_Materials.Count);
            for (int i = 0; i < m_Materials.Count; i++)
            {
                Component mat = null;
                if (m_Materials[i].instance != null)
                {
                    mat = dest.file.Bundle.FindComponent(m_Materials[i].instance.m_Name, UnityClassID.Material);
                    if (mat == null)
                    {
                        mat = m_Materials[i].instance.Clone(dest.file);
                    }
                    else if (mat is NotLoaded)
                    {
                        NotLoaded notLoaded = (NotLoaded)mat;
                        if (notLoaded.replacement != null)
                        {
                            mat = notLoaded.replacement;
                        }
                        else
                        {
                            mat = dest.file.LoadComponent(dest.file.SourceStream, notLoaded);
                        }
                    }
                }
                dest.m_Materials.Add(new PPtr<Material>(mat));
            }

            dest.m_SubsetIndices = (uint[])m_SubsetIndices.Clone();
            dest.m_UseLightProbes = m_UseLightProbes;
            dest.m_SortingLayerID = m_SortingLayerID;
            dest.m_SortingOrder = m_SortingOrder;
        }
Esempio n. 2
0
        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 FormRendererMeshAttributes(MeshRenderer meshR, int selectedSubmesh)
        {
            InitializeComponent();
            startSize = new SizeF(Width, Height);
            this.SaveDesignSizes();

            Text = meshR.classID1 + " " + meshR.m_GameObject.instance.m_Name + " Attributes";

            checkBoxRendererCastShadows.Checked = meshR.m_CastShadows;
            checkBoxRendererReceiveShadows.Checked = meshR.m_ReceiveShadows;
            editTextBoxRendererLightMap.Text = meshR.m_LightmapIndex.ToString();
            editTextBoxRendererTilingOffset.Text = "X:" + meshR.m_LightmapTilingOffset.X.ToFloatString() + ", Y:" + meshR.m_LightmapTilingOffset.Y.ToFloatString() + ", Z:" + meshR.m_LightmapTilingOffset.Z.ToFloatString() + ", W:" + meshR.m_LightmapTilingOffset.W.ToFloatString();
            checkBoxRendererSubsetIndices.Checked = meshR.m_SubsetIndices.Length > 0;
            editTextBoxRendererStaticBatchRoot.Text = meshR.m_StaticBatchRoot.instance != null ? meshR.m_StaticBatchRoot.instance.m_GameObject.instance.m_Name : String.Empty;
            checkBoxRendererUseLightProbes.Checked = meshR.m_UseLightProbes;
            editTextBoxRendererLightProbeAnchor.Text = meshR.m_LightProbeAnchor.instance != null ? meshR.m_LightProbeAnchor.instance.m_GameObject.instance.m_Name : String.Empty;
            editTextBoxRendererSortingLayerID.Text = meshR.m_SortingLayerID.ToString();
            editTextBoxRendererSortingOrder.Text = meshR.m_SortingOrder.ToString();

            if (meshR is SkinnedMeshRenderer)
            {
                SkinnedMeshRenderer smr= (SkinnedMeshRenderer)meshR;
                editTextBoxSkinnedMeshRendererQuality.Text = smr.m_Quality.ToString();
                checkBoxSkinnedMeshRendererUpdateWhenOffScreen.Checked = smr.m_UpdateWhenOffScreen;
                editTextBoxSkinnedMeshRendererBones.Text = smr.m_Bones.Count.ToString();
                editTextBoxSkinnedMeshRendererBlendShapeWeights.Text = smr.m_BlendShapeWeights.Count.ToString();
                editTextBoxSkinnedMeshRendererAABBCenter.Text = "X:" + smr.m_AABB.m_Center.X.ToFloatString() + ", Y:" + smr.m_AABB.m_Center.Y.ToFloatString() + ", Z:" + smr.m_AABB.m_Center.Z.ToFloatString();
                editTextBoxSkinnedMeshRendererAABBExtend.Text = "X:" + smr.m_AABB.m_Extend.X.ToFloatString() + ", Y:" + smr.m_AABB.m_Extend.Y.ToFloatString() + ", Z:" + smr.m_AABB.m_Extend.Z.ToFloatString();
                checkBoxSkinnedMeshRendererDirtyAABB.Checked = smr.m_DirtyAABB;
            }
            else
            {
                groupBoxSkinnedMeshRenderer.Enabled = false;
            }

            Mesh mesh = Operations.GetMesh(meshR);
            if (mesh != null)
            {
                editTextBoxMeshBlendShape.Text = mesh.m_Shapes.vertices.Count + "/" + mesh.m_Shapes.shapes.Count + "/" + mesh.m_Shapes.fullWeights.Count;
                editTextBoxMeshBindPose.Text = mesh.m_BindPose.Count.ToString();
                editTextBoxMeshBoneHashes.Text = mesh.m_BoneNameHashes.Count.ToString();
                checkBoxMeshCompression.Checked = mesh.m_MeshCompression > 0;
                checkBoxMeshStreamCompression.Checked = mesh.m_StreamCompression > 0;
                checkBoxMeshReadable.Checked = mesh.m_IsReadable;
                checkBoxMeshKeepVertices.Checked = mesh.m_KeepVertices;
                checkBoxMeshKeepIndices.Checked = mesh.m_KeepIndices;
                editTextBoxMeshInfluences.Text = mesh.m_Skin.Count.ToString();
                editTextBoxMeshUsageFlags.Text = mesh.m_MeshUsageFlags.ToString();
                editTextBoxMeshCenter.Text = "X:" + mesh.m_LocalAABB.m_Center.X.ToFloatString() + ", Y:" + mesh.m_LocalAABB.m_Center.Y.ToFloatString() + ", Z:" + mesh.m_LocalAABB.m_Center.Z.ToFloatString();
                editTextBoxMeshExtend.Text = "X:" + mesh.m_LocalAABB.m_Extend.X.ToFloatString() + ", Y:" + mesh.m_LocalAABB.m_Extend.Y.ToFloatString() + ", Z:" + mesh.m_LocalAABB.m_Extend.Z.ToFloatString();

                if (selectedSubmesh >= 0)
                {
                    editTextBoxSubmeshCenter.Text = "X:" + mesh.m_SubMeshes[selectedSubmesh].localAABB.m_Center.X.ToFloatString() + ", Y:" + mesh.m_SubMeshes[selectedSubmesh].localAABB.m_Center.Y.ToFloatString() + ", Z:" + mesh.m_SubMeshes[selectedSubmesh].localAABB.m_Center.Z.ToFloatString();
                    editTextBoxSubmeshExtend.Text = "X:" + mesh.m_SubMeshes[selectedSubmesh].localAABB.m_Extend.X.ToFloatString() + ", Y:" + mesh.m_SubMeshes[selectedSubmesh].localAABB.m_Extend.Y.ToFloatString() + ", Z:" + mesh.m_SubMeshes[selectedSubmesh].localAABB.m_Extend.Z.ToFloatString();
                }
            }
            else
            {
                groupBoxMesh.Enabled = false;
            }

            checkBoxRendererCastShadows.CheckedChanged += AttributeChanged;
            checkBoxRendererReceiveShadows.CheckedChanged += AttributeChanged;
            editTextBoxRendererLightMap.AfterEditTextChanged += AttributeChanged;
            editTextBoxRendererTilingOffset.AfterEditTextChanged += AttributeChanged;
            checkBoxRendererSubsetIndices.CheckedChanged += AttributeChanged;
            editTextBoxRendererStaticBatchRoot.AfterEditTextChanged += AttributeChanged;
            checkBoxRendererUseLightProbes.CheckedChanged += AttributeChanged;
            editTextBoxRendererSortingLayerID.AfterEditTextChanged += AttributeChanged;
            editTextBoxRendererSortingOrder.AfterEditTextChanged += AttributeChanged;
            editTextBoxRendererLightProbeAnchor.AfterEditTextChanged += AttributeChanged;
            editTextBoxSkinnedMeshRendererQuality.AfterEditTextChanged += AttributeChanged;
            checkBoxSkinnedMeshRendererUpdateWhenOffScreen.CheckedChanged += AttributeChanged;
            editTextBoxSkinnedMeshRendererAABBCenter.AfterEditTextChanged += AttributeChanged;
            editTextBoxSkinnedMeshRendererAABBExtend.AfterEditTextChanged += AttributeChanged;
            checkBoxSkinnedMeshRendererDirtyAABB.CheckedChanged += AttributeChanged;
            checkBoxMeshCompression.CheckedChanged += AttributeChanged;
            checkBoxMeshStreamCompression.CheckedChanged += AttributeChanged;
            checkBoxMeshReadable.CheckedChanged += AttributeChanged;
            checkBoxMeshKeepVertices.CheckedChanged += AttributeChanged;
            checkBoxMeshKeepIndices.CheckedChanged += AttributeChanged;
            editTextBoxMeshUsageFlags.AfterEditTextChanged += AttributeChanged;
            editTextBoxMeshCenter.AfterEditTextChanged += AttributeChanged;
            editTextBoxMeshExtend.AfterEditTextChanged += AttributeChanged;
        }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
 public void HighlightBone(MeshRenderer meshR, int boneIdx, bool show)
 {
     Operations.vMesh vMesh = new Operations.vMesh(meshR, false, true);
     int submeshIdx = 0;
     for (AnimationMeshContainer mesh = meshFrames[0].MeshContainer as AnimationMeshContainer;
          mesh != null;
          mesh = (AnimationMeshContainer)mesh.NextMeshContainer, submeshIdx++)
     {
         if (mesh.MeshData != null && mesh.MeshData.Mesh != null)
         {
             List<Operations.vVertex> vertexList = vMesh.submeshes[submeshIdx].vertexList;
             FillVertexBuffer(mesh.MeshData.Mesh, vertexList, show ? boneIdx : -1);
             if (show)
             {
                 Materials[mesh.MaterialIndex].Ambient = new Color4(unchecked((int)0xFF060660));
                 Materials[mesh.MaterialIndex].Emissive = Color.Black;
             }
             else
             {
                 Material mat = vMesh.submeshes[submeshIdx].matList[0].instance;
                 Materials[mesh.MaterialIndex].Ambient = GetColour(mat, "_SColor");
                 Materials[mesh.MaterialIndex].Emissive = GetColour(mat, "_ReflectColor");
             }
         }
         if (mesh.BoneLines != null)
         {
             if (boneIdx < mesh.BoneLines.Length / BoneObjSize)
             {
                 for (int j = 0; j < BoneObjSize; j++)
                 {
                     mesh.BoneLines[boneIdx * BoneObjSize + j].Color = show ? Color.Crimson.ToArgb() : Color.CornflowerBlue.ToArgb();
                 }
                 mesh.SelectedBone = boneIdx;
             }
         }
     }
 }