Esempio n. 1
0
        private void Start()
        {
            SplineRuntimeEditor.Created   += OnRuntimeEditorCreated;
            SplineRuntimeEditor.Destroyed += OnRuntimeEditorDestroyed;

            CreateRuntimeComponents();
            if (m_spline == null)
            {
                m_spline = GetComponentInParent <SplineBase>();
                if (m_spline == null)
                {
                    Debug.LogError("Is not a child of gameobject with Spline or MeshDeformer component");
                    return;
                }
                m_spline.ControlPointModeChanged     -= OnControlPointModeChanged;
                m_spline.ControlPointModeChanged     += OnControlPointModeChanged;
                m_spline.ControlPointPositionChanged -= OnControlPointPositionChanged;
                m_spline.ControlPointPositionChanged += OnControlPointPositionChanged;
            }

            m_localPosition         = m_spline.GetControlPointLocal(m_index);
            transform.localPosition = m_localPosition;

            UpdateMaterial();
        }
Esempio n. 2
0
        protected virtual void SceneGUIOverride()
        {
            if (m_splineBase == null)
            {
                m_splineBase = GetTarget();
            }

            if (m_splineBase == null)
            {
                return;
            }

            m_handleTransform = m_splineBase.transform;
            m_handleRotation  = Tools.pivotRotation == PivotRotation.Local ?
                                m_handleTransform.rotation : Quaternion.identity;

            Vector3 p0 = m_handleTransform.TransformPoint(m_splineBase.GetControlPointLocal(0));

            ShowPoint(0, p0);
            for (int i = 1; i < m_splineBase.ControlPointCount; i += 3)
            {
                Vector3 p1 = m_handleTransform.TransformPoint(m_splineBase.GetControlPointLocal(i));
                Vector3 p2 = m_handleTransform.TransformPoint(m_splineBase.GetControlPointLocal(i + 1));
                Vector3 p3 = m_handleTransform.TransformPoint(m_splineBase.GetControlPointLocal(i + 2));


                Handles.color = Color.gray;
                Handles.DrawLine(p0, p1);
                Handles.DrawLine(p2, p3);

                //if(m_spline.DrawGizmos)
                {
                    Handles.DrawBezier(p0, p3, p1, p2, Color.green, null, 1.8f);
                }

                ShowPoint(i, p1);
                ShowPoint(i + 1, p2);
                ShowPoint(i + 2, p3);
                p0 = p3;
            }
            //ShowDirections();
            //if(m_spline.DrawGizmos)
            {
                ShowTwistAngles();
            }
        }
Esempio n. 3
0
        private void Start()
        {
            SplineRuntimeEditor.Created        += OnRuntimeEditorCreated;
            SplineBase.ConvergingSplineChanged += OnIsConvergingChanged;

            CreateRuntimeComponents();
            if (m_spline == null)
            {
                m_spline = GetComponentInParent <SplineBase>();
                if (m_spline == null)
                {
                    Debug.LogError("Is not a child of gameobject with Spline or MeshDeformer component");
                    return;
                }

                m_spline.ControlPointTwistChanged      -= OnControlPointTwistChanged;
                m_spline.ControlPointTwistChanged      += OnControlPointTwistChanged;
                m_spline.ControlPointThicknessChanged  -= OnControlPointThicknessChanged;
                m_spline.ControlPointThicknessChanged  += OnControlPointThicknessChanged;
                m_spline.ControlPointModeChanged       -= OnControlPointModeChanged;
                m_spline.ControlPointModeChanged       += OnControlPointModeChanged;
                m_spline.ControlPointPositionChanged   -= OnControlPointPositionChanged;
                m_spline.ControlPointPositionChanged   += OnControlPointPositionChanged;
                m_spline.ControlPointConnectionChanged -= OnControlPointConnectionChanged;
                m_spline.ControlPointConnectionChanged += OnControlPointConnectionChanged;
            }

            m_localPosition         = m_spline.GetControlPointLocal(m_index);
            transform.localPosition = m_localPosition;

            UpdateRenderersState();
            UpdateAngle(true);
            m_rotation = transform.rotation;

            Thickness thickness = m_spline.GetThickness(m_index);

            transform.localScale = thickness.Data;

            if (!m_spline.IsSelected)
            {
                gameObject.SetActive(false);
            }
        }