UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Utility Systems / Collision System Completed

Utility Systems — UGTK

Collision System

Summary

The Collision System brings Unity's collision, trigger and pointer callbacks into the inspector. Instead of writing a script with OnTriggerEnter for every object that has to react, you drop a component and wire the reaction as a UnityEvent — the same way you wire a Button.

It covers three families: 3D physics, 2D physics, and pointer interaction (mouse or touch) on an object.


Content


Modules Dependencies

None. Four independent components that only use UnityEngine and UnityEngine.EventSystems.


Setup

3D physics — drop the collider prefab that matches the shape you need:

2D physics — the 2DColliderObject prefab:

Pointer interactionColliderMouse for the cursor, ColliderTouch for the finger:

Then wire the reactions in the inspector, like any UnityEvent:


How To Use

Mn_Collider3DEvents / Mn_Collider2DEvents expose the six physics callbacks:

Event Raised
onCollisionEnter / onCollisionEnter2D when the collision begins, with the collision data
onCollisionStay / onCollisionStay2D every physics step while it lasts
onCollisionExit / onCollisionExit2D when it ends
onTriggerEnter / onTriggerEnter2D when something enters the trigger, with the other collider
onTriggerStay / onTriggerStay2D every physics step while it is inside
onTriggerExit / onTriggerExit2D when it leaves

SetInteraction(false) silences the whole set without touching the collider: physics keeps behaving identically — the object still blocks, still pushes — only the reactions stop. That is the difference from disabling the collider, and it is usually what you want during a cutscene or a death animation.

Mn_ColliderMouse / Mn_ColliderTouch expose enter, over, exit, down, up and hold. The Hold event is the one Unity does not give you: it fires every frame while the press lasts, which is what a charge-up or a long-press needs.

Good to know:


What Unity Requires Anyway

This module wires the callbacks, it does not remove Unity's own requirements. Almost every "it does not fire" comes from one of these:


Testing Scene

Open Debug/CollisionScene.unity and press Play: the objects collide and CollisionCallbackExample logs every event it receives, so you can see which ones actually fire.


Technical Info

Path Content
Scripts/Mn_Collider3DEvents.cs The six 3D physics events plus SetInteraction
Scripts/2DCollision/Mn_Collider2DEvents.cs The six 2D physics events plus SetInteraction
Scripts/2DCollision/Mn_ColliderMouse.cs Mouse enter/over/exit/down/up/hold through the EventSystem
Scripts/2DCollision/Mn_ColliderTouch.cs The same for touch
Prefabs/3DColliders/*.prefab Box, Sphere and Capsule ready to use
Prefabs/2D/*.prefab 2D collider, mouse and touch
Debug/CollisionCallbackExample.cs, Debug/CollisionScene.unity Sample listener and test scene

© 2026 Marcello De Bonis. All rights reserved

Real dependenciesOpen in the map →

Measured from the repository: code references (asmdef) plus prefab and asset GUIDs. Importing this module alone brings in 0 modules in total.