C# Events in Unity

Published: 13 October 2023
on channel: XR Terra Class
31
3

This video explains how you can create your own custom events and subscribe functions to them from your C# scripts in Unity. Using an event system can help you when writing manager scripts and lets you avoid needing a reference to every component that needs to react to an event in your scene.

XRTerra Links:
Programs and Courses: http://www.xrterra.com/programs
Newsletter Signup: https://www.xrterra.com/mailing-list-...

00:00 Introducing Events
01:41 How to declare events
03:19 Remember to unsubscribe
04:02 Setting up a looping timer
06:07 Declaring and invoking the event
06:52 Null reference error
07:25 Creating Cube subscriber
07:52 Subscribing to event
09:06 Unsubscribing OnDestroy()
09:48 Testing move up cube event
10:13 Subscribing a second cube
12:22 Passing a parameter through the event
13:14 Subscription parameter mismatch
14:09 Testing out passed parameter

Instructor: Gregory Osborne


Watch video C# Events in Unity online without registration, duration hours minute second in high quality. This video was added by user XR Terra Class 13 October 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 31 once and liked it 3 people.