예제 #1
0
    /// <summary>
    /// Draw default manager params and action buttons
    /// </summary>
    private void InspectorDefaultGUI()
    {
        EditorGUILayout.PropertyField(pathPoints, new GUIContent("Path Points"));

        GUIStyle s = new GUIStyle(EditorStyles.largeLabel);

        s.fontStyle = FontStyle.Bold;

        GUILayout.Label("Default params", s);

        EditorGUILayout.Slider(offset, 0, 100, new GUIContent("Offset"));

        // Controls for gravity
        Rect position = EditorGUILayout.GetControlRect();

        GUIContent label           = EditorGUI.BeginProperty(position, new GUIContent("Last Point Gravity", "Copy gravity value from the last point"), useLastPointGravity);
        Rect       contentPosition = EditorGUI.PrefixLabel(position, label);
        int        indent          = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        contentPosition.width        *= 0.25f;
        useLastPointGravity.boolValue = EditorGUI.Toggle(contentPosition, useLastPointGravity.boolValue);

        // Gravity field enabled only if LastPointGravity is unchecked
        GUI.enabled = !useLastPointGravity.boolValue;

        contentPosition.x += contentPosition.width * 2;
        EditorGUI.LabelField(contentPosition, "Gravity");

        contentPosition.x += contentPosition.width;
        EditorGUI.PropertyField(contentPosition, gravity, GUIContent.none);

        GUI.enabled = true;

        EditorGUI.indentLevel = indent;
        EditorGUI.EndProperty();

        // Actions buttons
        GUILayout.Label("Actions", EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Add"))
        {
            _target.activeIndex = _target.AddPoint();
            SceneView.RepaintAll();
        }
        if (GUILayout.Button("Delete"))
        {
            _target.DeletePoint();
            SceneView.RepaintAll();
        }
        if (GUILayout.Button("Delete All"))
        {
            if (EditorUtility.DisplayDialog("Delete all points?", "You really want to delete all points?", "Yes", "No"))
            {
                _target.DeleteAllPoints();
                SceneView.RepaintAll();
            }
        }

        GUILayout.EndHorizontal();
    }