/// <summary>
            /// Called by the extrusion sequence prior to extruding
            /// </summary>
            public void RuntimeInitialize()
            {
                if (transform == null)
                {
                    _error = true;
                    return;
                }
                localToWorldMatrix = transform.localToWorldMatrix;
                localScale         = transform.localScale;

#if DREAMTECK_SPLINES
                if (extrusionSettings.bendSpline && splineComputer != null)
                {
                    splineComputer.ResampleTransform();
                }
                else
                {
                    extrusionSettings.bendSpline = false;
                }
#endif
                if (meshFilter != null)
                {
                    _originalMesh = meshFilter.sharedMesh;
                    if (extrusionSettings.bendMesh)
                    {
                        extrusionMesh = new TS_Mesh(_originalMesh);
                    }
                }
                else
                {
                    extrusionSettings.bendMesh = false;
                }

                if (spriteRenderer != null)
                {
                    if (spriteRenderer.sprite != null)
                    {
                        extrusionSpriteVertices = spriteRenderer.sprite.vertices;
                        extrusionSpriteUVs      = spriteRenderer.sprite.uv;
                    }
                }
                else
                {
                    extrusionSettings.bendSprite = false;
                }

                if (meshCollider != null)
                {
                    _originalCollisionMesh = meshCollider.sharedMesh;
                    if (extrusionSettings.meshColliderHandling == ExtrusionSettings.MeshColliderHandling.Extrude)
                    {
                        extrusionCollisionMesh = new TS_Mesh(_originalCollisionMesh);
                    }
                }
                else if (extrusionSettings.meshColliderHandling == ExtrusionSettings.MeshColliderHandling.Extrude)
                {
                    extrusionSettings.meshColliderHandling = ExtrusionSettings.MeshColliderHandling.Bypass;
                }
            }
Esempio n. 2
0
            internal SplineComputer CreateSplineComputer(Vector3 position, Quaternion rotation)
            {
                GameObject go = new GameObject(name);

                go.transform.position = position;
                go.transform.rotation = rotation;
                SplineComputer computer = go.AddComponent <SplineComputer>();

#if UNITY_EDITOR
                if (Application.isPlaying)
                {
                    computer.ResampleTransform();
                }
#endif
                computer.type = type;
                if (closed)
                {
                    if (points[0].type == SplinePoint.Type.Broken)
                    {
                        points[0].SetTangentPosition(GetLastPoint().tangent2);
                    }
                }
                computer.SetPoints(points.ToArray(), SplineComputer.Space.Local);
                if (closed)
                {
                    computer.Close();
                }
                return(computer);
            }