private void DuringSceneGUI(SceneView sceneView) { Selection.activeObject = m_WaypointCreater; bool holdingShift = (Event.current.modifiers & EventModifiers.Shift) != 0; bool holdingCtl = (Event.current.modifiers & EventModifiers.Control) != 0; Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { if (Event.current.type == EventType.MouseDown && holdingShift) { if (m_PropInsertPoint.boolValue && m_PropWaypoints.arraySize > 2) { Undo.RegisterCompleteObjectUndo(m_WaypointCreater, "add point"); m_WaypointCreater.InsertPoint(hit.point); } else { Undo.RegisterCompleteObjectUndo(m_WaypointCreater, "add point"); m_WaypointCreater.CreateWaypoint(hit.point); } } if (Event.current.type == EventType.MouseDown && holdingCtl) { Undo.RegisterCompleteObjectUndo(m_WaypointCreater, "selected point"); m_WaypointCreater.RemoveWaypoint(hit.point); } } m_SerializedObject.Update(); if (m_PropWaypoints.arraySize > 0) { for (int i = 0; i < m_PropWaypoints.arraySize; i++) { SerializedProperty prop = m_PropWaypoints.GetArrayElementAtIndex(i); prop.vector3Value = Handles.PositionHandle(prop.vector3Value, Quaternion.identity); Handles.color = m_PropColor.colorValue; Handles.SphereHandleCap(-1, prop.vector3Value, Quaternion.identity, m_PropPointRadius.floatValue, EventType.Repaint); Handles.Label(prop.vector3Value, "Point " + i.ToString()); if (m_PropWaypoints.arraySize > 1) { Handles.DrawDottedLine(prop.vector3Value, m_PropWaypoints.GetArrayElementAtIndex(m_WaypointCreater.GetNextIndex(i)).vector3Value, m_ScreenSize); } } } m_SerializedObject.ApplyModifiedProperties(); }
private void CycleWaypoint() { m_CurrentWaypointIndex = m_Waypoint.GetNextIndex(m_CurrentWaypointIndex); }