Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

MonoBehavior Messages

Gauthier Billot edited this page Jun 29, 2017 · 6 revisions

To help bridge the gap between EgoCS and Unity3D, EgoCS provides special Components that convert MonoBehaviour Messages (OnCollisionEnter, OnTriggerLeave, etc) to EgoCS events.

The EgoCS Component and generated EgoCS Event Object, have corresponding names to their MonoBehavior Message:

MonoBehavior Message EgoCS Component EgoCS Event
Onname OnnameComponent nameEvent

For example, you could attach an OnCollisionEnterComponent to a GameObject. When that GameObject starts colliding with something else, Unity3D will call the OnCollisionEnter() method in the OnCollisionEnterComponent. Then, in OnCollisionEnter(), a new CollisionEnterEvent is created and added to the EgoCS Event Queue.

MonoBehavior Message EgoCS Component EgoCS Event
OnCollisionEnter() OnCollisionEnterComponent CollisionEnterEvent
OnCollisionStay() OnCollisionStayComponent CollisionStayEvent
OnCollisionExit() OnCollisionExitComponent CollisionExitEvent
OnCollisionEnter2D() OnCollisionEnter2DComponent CollisionEnter2DEvent
OnCollisionStay2D() OnCollisionStay2DComponent CollisionStay2DEvent
OnCollisionExit2D() OnCollisionExit2DComponent CollisionExit2DEvent
OnMouseDown() OnMouseDownComponent MouseDownEvent
OnMouseDrag() OnMouseDragComponent MouseDragEvent
OnMouseEnter() OnMouseEnterComponent MouseEnterEvent
OnMouseExit() OnMouseExitComponent MouseExitEvent
OnMouseUp() OnMouseUpComponent MouseUpEvent
OnMouseUpAsButton() OnMouseUpAsButtonComponent MouseUpAsButtonEvent
OnTriggerStay() OnTriggerStayComponent TriggerStayEvent
OnTriggerExit() OnTriggerExitComponent TriggerExitEvent
OnTriggerEnter2D() OnTriggerEnter2DComponent TriggerEnter2DEvent
OnTriggerStay2D() OnTriggerStay2DComponent TriggerStay2DEvent
OnTriggerExit2D() OnTriggerExit2DComponent TriggerExit2DEvent

For now, EgoCS only converts the common collision MonoBehavior Messages to EgoEvents, but more will be added in the future.