Exemplo n.º 1
0
 private void Start()
 {
     //TODO move in attribute creation
     _iProcGenHook = new IProcGenElementProperty();
     renderer      = GetComponent <LineRenderer>();
     rail          = GetComponentInParent <CentralizedRail>();
 }
    private void OnEnable()
    {
        _focusedControlPointIndex = 0;

        rail = serializedObject.FindProperty("rail").objectReferenceValue as CentralizedRail;

        controls = serializedObject.FindProperty("_iProcGenHook");

        trackName     = serializedObject.FindProperty("trackName");
        closed        = serializedObject.FindProperty("closed");
        step          = serializedObject.FindProperty("step");
        controlPoints = serializedObject.FindProperty("controlPoints");

        controlPointList = new ReorderableList(serializedObject, controlPoints, true, true, true, true)
        {
            // Draw header label
            drawHeaderCallback = (Rect rect) => {
                EditorGUI.LabelField(rect, "Control Points");
            },

            elementHeightCallback = (int index) => {
                var elementHeight = EditorGUIUtility.singleLineHeight;
                // optional, depending on the situation in question and the defaults you like
                // you may want to subtract the margin out in the drawElementCallback before drawing
                var margin = EditorGUIUtility.standardVerticalSpacing;
                return(elementHeight + margin);
            },

            drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
                if (isFocused)
                {
                    _newFocusedControlPointIndex = index;
                }

                var element = controlPointList.serializedProperty.GetArrayElementAtIndex(index);

                EditorGUI.LabelField(
                    new Rect(rect.x, rect.y, rect.width - 30, EditorGUIUtility.singleLineHeight),
                    element.FindPropertyRelative("label").stringValue);
            }
        };
    }