Unity Using Events and Building Effective UI Systems

September 7, 2021

Unity Events

UI Systems


Title:
C# Events in Unity! – Intermediate Scripting Tutorial

By:
Unity


Youtube Link – Tutorial #1

Description:
Brief introduction to using Events in Unity.


Title:
How To Build An Event System in Unity

By:
Game Dev Guide


Youtube Link – Tutorial #2

Description:
Quick showing of implementing a basic Event system in Unity for gameplay reasons.


Title:
Delegates, Events, Actions and Funcs – The Observer Pattern (Unity & C#)

By:
One Wheel Studio


Youtube Link – Tutorial #3

Description:
Covers Events, as well as Delegates, Actions, and Funcs specifically through the Observer Pattern in Unity.


Title:
Game Architecture Tips – Event Driven UI – Unity

By:
Dapper Dino


Youtube Link – Tutorial #4

Description:
An Event system built in Unity specifically with a focus on UI.


Title:
Building Unity UI that scales for a real game – Prefabs/Scenes?

By:
Jason Weimann


Youtube Link – Tutorial #5

Description:
General coverage of building effective UI systems in Unity.


Overview

I wanted to delve further into using Event systems in Unity specifically when building UI systems, so I collected a few resources I thought would help with researching that. These tutorials cover everything from the basic foundations of Events themselves to fully fledged UI system tutorials near the end implementing those tools and concepts covered in the earlier tutorials.

I think Event heavy systems are very effective ways to build out UI in games, so I want to get a better grasp of setting that up. I especially think the final tutorial by Jason Weimann will help bring those topics together as well as cover other important factors for building larger scale UI systems.

via Blogger http://stevelilleyschool.blogspot.com/2021/09/unity-using-events-and-building.html

Unity Event Systems: Introductory Research

December 17, 2019

Unity Event Systems

Basics, Setup, and Tutorials

ADDENDUM: An EVEN MORE AWESOME Event System, by viewers!

Link – Tutorial 1

By: quill18creates


C# Events

Link – Tutorial 2

By: Jonathan Weinberger {ON Unity Learn Premium}


Tutorial 1

They created a public abstract class, Event, that all types of events will just inherit from. This helps keep all your events nice and similar, as well as making sure they all have key methods such as those necessary for registering and unregistering listeners. Since each event type is its own version of this base event, they can each hold a different collection of listeners, which makes sense since you only want certain behaviors to happen when certain events happen (such as a unit dying).

Inheritance and Static Fields in C#

This was an interesting interaction that I did not know it worked this way. When a base class in C# contains a static field, and then you create a new class that inherits from this class, it actually creates its own separate and unique version of that static field (as opposed to their just being one overall static field contained in the base class for all classes that inherit it). This has pros and cons. The pros are that it is helpful when you want the derived classes to be able to hold data only amongst themselves. The cons are obviously that you will have to do something a bit extra if you want something to contain all the information from all derived classes from that original base class.

Tutorial 2

This is just a very basic intro to events in C# I found on Unity Learn premium. This was beneficial to just cover some basic rules of events in general again.

General Events Notes

  • allow us to create broadcast system so other objects can subscribe/unsubscribe
  • need delegate type
  • will cause an error if it’s null when called
  • helps classes be self contained (since they do not rely on communication directly with another object)
  • every instance of an object that wants to be subscribed to the event must make sure that it itself subscribes
  • have inherent security (as opposed to delegates)
  • General Rule: always have an unsubscribe for every subscribe

Final Notes

Unity Learn actually has a ton of information, tutorials, and practice for learning about events, so I will most likely look to follow some of them in the future. They range from a few more really basic ones such as the one I just checked out, to more challenging ones, and even advanced ones that are much more project based as well. I really think this type of system will be useful for my current personal project, so I want to understand it well in an effort to properly utilize it.

Callbacks and Event Systems

March 18, 2019

Creating an Event System in Unity

Event System with Callbacks Tutorial

Youtube – Unity Tutorial: Callbacks and a (Really Awesome!) Event System

By: quill18creates

Following in my learning of delegates and events, I stumbled across an interesting tutorial on creating Event Systems in Unity. I just wanted to note this as something to follow up on in the future since the general concepts I got from skimming through sounded very promising and good to learn about.