Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            EditorGUI.BeginChangeCheck();

            _freeMoveHandleRadius = EditorGUILayout.Slider("Handle cap radius", _freeMoveHandleRadius, 0, 1);
            _snapIncrement        = EditorGUILayout.Slider("Snap Value", _snapIncrement, 0.1f, 1f);
            var waypoint = _waypoints.IsEmpty ? Vector3.zero : _waypoints.GetSelected();

            _waypoints.UpdateSelected(EditorGUILayout.Vector3Field("Selected point", waypoint));

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Add"))
            {
                if (_waypoints.IsEmpty)
                {
                    _waypoints.Items.Add(_platform.transform.position);
                }
                else
                {
                    _waypoints.InsertAfterSelected(_waypoints.GetSelected() + Vector3.forward);
                    _waypoints.SelectNext();
                }

                Undo.RecordObject(target, "Added point");
            }

            if (GUILayout.Button("Delete"))
            {
                _waypoints.RemoveSelected();
                Undo.RecordObject(target, "Deleted point");
            }

            GUILayout.EndHorizontal();

            if (GUILayout.Button("Snap"))
            {
                SnapPoints(_snapIncrement);
                Undo.RecordObject(target, "Snapped points");
            }

            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
        }