예제 #1
0
    public void DrawSplineInfo(string title, BezierSpline spline, int index)
    {
        if (spline == null) return;

        GUI.color = new Color(0,0,0,0);
        if (GUILayout.Button("","Foldout")) {
            edgeExpanded[index] = !edgeExpanded[index];
        }
        GUI.color = new Color(1,1,1,1);

        edgeExpanded[index] = EditorGUI.Foldout(GUILayoutUtility.GetLastRect(),edgeExpanded[index],title);

        if (!edgeExpanded[index]) {
            return;
        }

        Rect rect = EditorGUILayout.BeginVertical();
        if (!spline.linear) {
            rect.x += 4;
            rect.width -= 4;
        }
        GUI.Box(rect,"");
        GUILayout.Space(4);

        EditorGUI.indentLevel = EditorGUI.indentLevel+1;
        spline.linear = EditorGUILayout.Toggle("Linear",spline.linear);
        if (!spline.linear) {
            spline.useCustomDistance = EditorGUILayout.Toggle("Custom Distance",spline.useCustomDistance);
            if (spline.useCustomDistance) {
                GUILayout.BeginHorizontal();
                spline.customDistance0 = EditorGUILayout.FloatField("P1 Distance",spline.customDistance0);
                if (GUILayout.Button("Reset",GUILayout.MaxWidth(50))) {
                    spline.customDistance0 = 1.0f/3.0f;
                }
                if (GUILayout.Button("O",GUILayout.MaxWidth(25))) {
                    spline.customDistance0 = 0.5f-((0.5f-(1.0f/3.0f))*0.5f);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                spline.customDistance1 = EditorGUILayout.FloatField("P2 Distance",spline.customDistance1);
                if (GUILayout.Button("Reset",GUILayout.MaxWidth(50))) {
                    spline.customDistance1 = 1.0f/3.0f;
                }
                if (GUILayout.Button("O",GUILayout.MaxWidth(25))) {
                    spline.customDistance1 = 0.5f-((0.5f-(1.0f/3.0f))*0.5f);
                }
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset Tangents")) {
                spline.SetLinearTangents();
            }
            GUILayout.EndHorizontal();
            spline.localNormal0 = EditorGUILayout.Vector3Field("P1 Tangent",spline.localNormal0);
            spline.localNormal1 = EditorGUILayout.Vector3Field("P2 Tangent",spline.localNormal1);
        }
        EditorGUI.indentLevel = EditorGUI.indentLevel-1;
        GUILayout.Space(4);
        EditorGUILayout.EndVertical();
    }