|
|
|
|
|
|
using UnityEditorInternal; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
[CustomEditor(typeof(Pathway))] |
|
|
|
[CustomEditor(typeof(PathwayConfigSO))] |
|
|
|
private Pathway _pathway; |
|
|
|
private PathwayConfigSO _pathway; |
|
|
|
private PathwayHandles _pathwayHandles; |
|
|
|
private PathWayNavMeshUI _pathWayNavMeshUI; |
|
|
|
private enum LIST_MODIFICATION { ADD, SUPP, DRAG, OTHER }; |
|
|
|
|
|
|
public void OnSceneGUI() |
|
|
|
public void OnSceneGUI(SceneView sceneView) |
|
|
|
PathwayGizmos.DrawGizmosSelected(_pathway); |
|
|
|
} |
|
|
|
|
|
|
|
public override void OnInspectorGUI() |
|
|
|
|
|
|
_reorderableList.DoLayoutList(); |
|
|
|
_pathWayNavMeshUI.OnInspectorGUI(); |
|
|
|
Tools.hidden = _pathway.HidePathway; |
|
|
|
serializedObject.ApplyModifiedProperties(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
_reorderableList.onRemoveCallback += RemoveItem; |
|
|
|
_reorderableList.onChangedCallback += ListModified; |
|
|
|
_reorderableList.onMouseDragCallback += DragItem; |
|
|
|
_pathway = (target as Pathway); |
|
|
|
_pathway = (target as PathwayConfigSO); |
|
|
|
SceneView.duringSceneGui += this.OnSceneGUI; |
|
|
|
} |
|
|
|
|
|
|
|
private void OnDisable() |
|
|
|
|
|
|
_reorderableList.onRemoveCallback -= RemoveItem; |
|
|
|
_reorderableList.onChangedCallback -= ListModified; |
|
|
|
_reorderableList.onMouseDragCallback -= DragItem; |
|
|
|
_pathway.waypoints = _pathway.Waypoints.Select(x => x.waypoint).ToArray(); |
|
|
|
SceneView.duringSceneGui -= this.OnSceneGUI; |
|
|
|
GUI.Label(rect, Pathway.TITLE_LABEL); |
|
|
|
GUI.Label(rect, PathwayConfigSO.TITLE_LABEL); |
|
|
|
item.vector3Value = EditorGUI.Vector3Field(rect, Pathway.FIELD_LABEL + index, item.vector3Value); |
|
|
|
item.vector3Value = EditorGUI.Vector3Field(rect, PathwayConfigSO.FIELD_LABEL + index, item.vector3Value); |
|
|
|
} |
|
|
|
|
|
|
|
private void AddItem(ReorderableList list) |
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
list.serializedProperty.InsertArrayElementAtIndex(list.serializedProperty.arraySize); |
|
|
|
Vector3 previous = _pathway.transform.position; |
|
|
|
Vector3 previous = Vector3.zero; |
|
|
|
list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).FindPropertyRelative("waypoint").vector3Value = new Vector3(previous.x + 2, previous.y, previous.z + 2); |
|
|
|
_indexCurrentModification = list.serializedProperty.arraySize - 1; |
|
|
|
} |
|
|
|