コード例 #1
0
 void Start()
 {
     mesh      = new Mesh();
     mesh.name = "StalkMesh";
     GetComponent <MeshFilter>().sharedMesh = mesh;
     deformer = GetComponent <Deform.Deformable>();
     setMesh();
     GetComponent <Deform.Deformable>().InitializeData();
     GetComponent <Deform.Deformable>().ChangeMesh(mesh);
 }
コード例 #2
0
ファイル: LatticeDeformer.cs プロジェクト: thecrazy/Deform
        public void FitBoundsToParentDeformable()
        {
            Deformable deformable = transform.GetComponentInParent <Deformable>();

            if (deformable == null)
            {
                // No deformable above the lattice, so next see if there's a LODGroup with a deformable on the first LOD
                LODGroup lodGroup = transform.GetComponentInParent <LODGroup>();
                var      lods     = lodGroup.GetLODs();
                if (lods.Length != 0 && lods[0].renderers.Length != 0 && lods[0].renderers[0] != null)
                {
                    deformable = lods[0].renderers[0].GetComponent <Deformable>();
                }
            }

            if (deformable != null)
            {
                var bounds = deformable.GetCurrentMesh().bounds;
                transform.localPosition = bounds.center;
                transform.localScale    = bounds.size;
                // Make sure the rotation is zeroed so that we're not applying the size is the wrong axis
                transform.localRotation = Quaternion.identity;
            }
        }