You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Driftology/Assets/Waypoint System/Editor/WaypointCircuitEditor.cs

37 lines
1.1 KiB
C#

2 months ago
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(WaypointCircuit))]
public class WaypointCircuitEditor : Editor
{
private WaypointCircuit _script;
public override void OnInspectorGUI()
{
EditorGUILayout.HelpBox("Create Waypoint By Press Shift + Left Mouse Click On Your Road", MessageType.Info);
DrawDefaultInspector();
_script = (WaypointCircuit)target;
}
public void OnSceneGUI()
{
Event e = Event.current;
if (e != null && e.isMouse && e.shift && e.type == EventType.MouseDown)
{
Ray worldRay = HandleUtility.GUIPointToWorldRay(e.mousePosition);
if (Physics.Raycast(worldRay, out RaycastHit hitInfo))
{
_script.PlaceWaypoint(hitInfo.point);
}
else
{
Debug.LogWarning("Waypoint Manager: Trying to place a waypoint but couldn't find a valid target. Have you clicked on a collider?");
}
if (_script != null)
Selection.activeGameObject = _script.gameObject;
}
}
}