Beispiel #1
0
 /// <summary>
 /// Same as Spline.Close() but it will update all subscribed users
 /// </summary>
 public void Close()
 {
     if (!spline.isClosed)
     {
         spline.Close();
         Rebuild();
     }
 }
            public BendProperty(Transform t, bool isParent = false)
            {
                parent           = isParent;
                transform        = new TS_Transform(t);
                originalPosition = t.localPosition;
                originalScale    = t.localScale;
                originalRotation = t.localRotation;
                parentRotation   = t.transform.rotation;
                if (t.transform.parent != null)
                {
                    parentRotation = t.transform.parent.rotation;
                }
                filter   = t.GetComponent <MeshFilter>();
                collider = t.GetComponent <MeshCollider>();
                if (filter != null && filter.sharedMesh != null)
                {
                    originalMesh = filter.sharedMesh;
                    normals      = originalMesh.normals;
                    for (int i = 0; i < normals.Length; i++)
                    {
                        normals[i] = transform.transform.TransformDirection(normals[i]).normalized;
                    }
                }

                if (collider != null && collider.sharedMesh != null)
                {
                    originalColliderMesh = collider.sharedMesh;
                    colliderNormals      = originalColliderMesh.normals;
                    for (int i = 0; i < colliderNormals.Length; i++)
                    {
                        colliderNormals[i] = transform.transform.TransformDirection(colliderNormals[i]);
                    }
                }
                if (!parent)
                {
                    splineComputer = t.GetComponent <SplineComputer>();
                }
                if (splineComputer != null)
                {
                    if (splineComputer.isClosed)
                    {
                        originalSpline.Close();
                    }
                    destinationSpline        = new Spline(originalSpline.type);
                    destinationSpline.points = new SplinePoint[originalSpline.points.Length];
                    destinationSpline.points = splineComputer.GetPoints();
                    if (splineComputer.isClosed)
                    {
                        destinationSpline.Close();
                    }
                }
            }