Skip to content

Commit

Permalink
EventVolume: QoL improvements.
Browse files Browse the repository at this point in the history
This adds "Event Volume" to the Create/3D Object menu.

Signed-off-by: Raven <[email protected]>
  • Loading branch information
az-raven committed Oct 11, 2023
1 parent 31550fa commit 9d6cbf3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions EventVolume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
using UnityEngine;
using UnityEngine.Events;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace SubsurfaceStudios {
public sealed class EventVolume : MonoBehaviour {
public LayerMask m_PlayerLayerMask;
Expand Down Expand Up @@ -30,5 +34,20 @@ void OnTriggerExit(Collider other) {
m_OnObjectExit.Invoke();
}
}

#if UNITY_EDITOR
[MenuItem("GameObject/3D Object/Event Volume", false, 10)]
static void CreateEventVolume(MenuCommand command) {
GameObject go = new("Event Volume");
GameObjectUtility.SetParentAndAlign(go, command.context as GameObject);

Undo.RegisterCreatedObjectUndo(go, $"Create {go.name}");
Selection.activeObject = go;

Collider c = go.AddComponent<BoxCollider>();
c.isTrigger = true;
go.AddComponent<EventVolume>();
}
#endif
}
}

0 comments on commit 9d6cbf3

Please sign in to comment.