Пример #1
0
    protected static SplineComponent SplineOfControlPoint(SplineControlPointComponent l_ControlPoint)
    {
        SplineComponent l_Result = null;
        Transform l_Transform = l_ControlPoint.transform;

        while (l_Result == null) {
            if (l_Transform.parent == null) {
                break;
            }
            l_Transform = l_Transform.parent;
            l_Result = l_Transform.GetComponent <SplineComponent> ();
        }

        return (l_Result);
    }
Пример #2
0
    public static void DrawSplineControlPoint(SplineControlPointComponent a_ControlPoint, GizmoType a_Type)
    {
        Color l_GizmosColor = Gizmos.color;

        SplineComponent l_Spline = SplineOfControlPoint (a_ControlPoint);
        if (l_Spline != null && l_Spline.Spline.Count > 0) {
            if (a_ControlPoint == l_Spline.Spline [0] || a_ControlPoint == l_Spline.Spline [l_Spline.Spline.Count - 1]) {
                Gizmos.color = SplineWindow.StartEndPointColor;
            } else {
                Gizmos.color = SplineWindow.DefaultColor;
            }

            Gizmos.DrawSphere (a_ControlPoint.transform.position, SplineWindow.SelectableSphereRadius);
        }

        Gizmos.color = l_GizmosColor;
    }
Пример #3
0
    protected void OnSelectionChange()
    {
        Initialize ();

        s_SelectedControlPoint = null;

        if (Selection.activeTransform != null) {
            SplineControlPointComponent l_SelectedControlPoint = Selection.activeTransform.GetComponent <SplineControlPointComponent> ();
            if (l_SelectedControlPoint != null) {
                s_SelectedControlPoint = l_SelectedControlPoint;
            }
        }

        Repaint ();
    }
Пример #4
0
    protected void GizmoOptions()
    {
        bool l_MouseDown = (Event.current.type == EventType.mouseDown);
        Vector2 l_MousePosition = Event.current.mousePosition;

        Rect l_Rect = EditorGUILayout.BeginVertical ();
        s_GizmoOptionsFoldout = EditorGUILayout.Foldout (s_GizmoOptionsFoldout, "Gizmo options");
        if (s_GizmoOptionsFoldout) {
            int l_CurveSegmentCount = EditorGUILayout.IntField ("Curve segments", s_CurveSegmentCount);
            if (l_CurveSegmentCount >= 1) {
                s_CurveSegmentCount = l_CurveSegmentCount;
            }
            int l_CurveSphereCount = EditorGUILayout.IntField ("Curve spheres", s_CurveSphereCount);
            if (l_CurveSphereCount >= 0) {
                s_CurveSphereCount = l_CurveSphereCount;
            }
            float l_SphereRadius = EditorGUILayout.FloatField ("Sphere radius", s_SphereRadius);
            if (l_SphereRadius > 0.0f) {
                s_SphereRadius = l_SphereRadius;
            }
        }
        EditorGUILayout.EndVertical ();

        if (l_MouseDown && l_Rect.Contains (l_MousePosition)) {
            Event.current.Use ();
            s_SelectedControlPoint = null;
        }
    }
Пример #5
0
    protected void ControlPointList()
    {
        bool l_MouseDown = (Event.current.type == EventType.mouseDown);
        Vector2 l_MousePosition = Event.current.mousePosition;

        EditorGUIUtility.LookLikeInspector ();

        for (int i = 0; i < s_Spline.Spline.ControlPoints.Count; i = i + 1) {
            SplineControlPointComponent l_ControlPoint = s_Spline.Spline.ControlPoints [i];
            Rect l_Rect = EditorGUILayout.BeginHorizontal ();
            GUI.SetNextControlName (l_ControlPoint.GetInstanceID ().ToString ());

            string l_Name = l_ControlPoint.name;
            if (i == 0) {
                l_Name = "(Entry) " + l_Name;
            } else if (i == s_Spline.Spline.Count - 1) {
                l_Name = "(Exit) " + l_Name;
            } else {
                l_Name = i.ToString () + " " + l_Name;
            }

            l_ControlPoint.T = EditorGUILayout.FloatField (l_Name, l_ControlPoint.T);
            EditorGUILayout.EndHorizontal ();

            if (l_MouseDown && l_Rect.Contains (l_MousePosition)) {
                s_SelectedControlPoint = l_ControlPoint;
                Selection.activeGameObject = s_SelectedControlPoint.gameObject;
            }
        }

        if (!l_MouseDown && s_SelectedControlPoint != null) {
            GUI.FocusControl (s_SelectedControlPoint.GetInstanceID ().ToString ());
        }

        EditorGUILayout.BeginHorizontal ();
        GUI.enabled = false;
        EditorGUILayout.FloatField ("Length", s_Spline.Spline.SplineLength (c_SubStepsPerSegment));
        GUI.enabled = true;
        EditorGUILayout.EndHorizontal ();
    }
Пример #6
0
 protected static void ValidateSelection()
 {
     if (s_SelectedControlPoint != null && s_Spline != null) {
         if (!s_Spline.Spline.Contains (s_SelectedControlPoint)) {
             s_SelectedControlPoint = null;
         }
     }
 }