{"id":14960537,"url":"https://github.com/stephenmcvicker/unity-scriptableobjects-game-events-","last_synced_at":"2025-05-02T12:31:26.704Z","repository":{"id":96574397,"uuid":"141692856","full_name":"StephenMcVicker/Unity-ScriptableObjects-Game-Events-","owner":"StephenMcVicker","description":"Based on a great talk by Ryan Hipple, here is my improved version of his Game Event system for Unity","archived":false,"fork":false,"pushed_at":"2019-02-20T16:00:02.000Z","size":75,"stargazers_count":151,"open_issues_count":0,"forks_count":19,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-25T21:38:12.503Z","etag":null,"topics":["csharp","event-system","unity","unity2d","unity3d","unity3d-plugin","unityplugin"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StephenMcVicker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-07-20T09:32:32.000Z","updated_at":"2025-02-18T07:53:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"c92cc4ea-736e-48f4-acf4-9e53709aafb1","html_url":"https://github.com/StephenMcVicker/Unity-ScriptableObjects-Game-Events-","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMcVicker%2FUnity-ScriptableObjects-Game-Events-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMcVicker%2FUnity-ScriptableObjects-Game-Events-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMcVicker%2FUnity-ScriptableObjects-Game-Events-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMcVicker%2FUnity-ScriptableObjects-Game-Events-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephenMcVicker","download_url":"https://codeload.github.com/StephenMcVicker/Unity-ScriptableObjects-Game-Events-/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038155,"owners_count":21684632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","event-system","unity","unity2d","unity3d","unity3d-plugin","unityplugin"],"created_at":"2024-09-24T13:22:28.710Z","updated_at":"2025-05-02T12:31:26.345Z","avatar_url":"https://github.com/StephenMcVicker.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Unity: ScriptableObjects Game Events System\n\n\nBased on a great talk by Ryan Hipple, here is my improved version of his Game Event system for Unity\n\n\n**Quick Note:**\nThis project doesn't use any namespaces. \nConflicts with your own code may happen if you have any classes named the same.\nThere are 3 classes:\nGameEvent\nEventListener\nEventAndResponse\n\n## Why use this\n\nAt Unite Austin 2017, Ryan Hipple talked about the advantage of using scriptable objects in Unity. \nThe video is here (HIS TALK):\nhttps://youtu.be/raQ3iHhE_Kk?t=1964\nAround 32 minutes in, he talks about creating an event system that allows you and your team to quickly work on features that can act independently. His example: Imagine a designer was working on a player HP bar. He would need to bring in the player into his test scene, maybe some sort of manager, and who knows what else just to do this one thing. With his system using Game Events, you can create a player \"take damage\" event and have the UI for the HP bar just listen to this event. The best part: You don't even need the player in the scene. Watch his video. He explains it better.\n\nI started using his system but found it got pretty complex adding lots of Event Listener to a single game object so I changed up the code to make it list based. You add just 1 Event Listener component to your GameObject and you can add as many events as you want and as many responses to each event as you want.\n\nHere is MY video on it:\nhttps://www.youtube.com/watch?v=1ZK63Mp6yTY\nIn my example, I set up an Input field. I have a simple script that once finished inputting it checks the length of the string. \nThe script has 2 Game Events. \n1 for if it has enough characters and 1 if there isn't enough.\nIn the if statement of the script, simply Raise the correct Game Event. Anything that is listening to the event will react.\nAdd an Event Listener. \nListen for each game event and just add what you want to happen if either is raised. This is really designer-friendly as adding new events is as easy as: \"Create \u003e Game Event\" in your project window.\n\n\n## Installation\nJust download the files and drag the EventSystem folder into your Asset folder (or any subfolder of your creation) in Unity.\n\n## Usage and Sample Project\n\nStart by creating a game event:\n\n![CreateGameEvent](https://i.imgur.com/MKbDJDu.png)\n\nYou will need something to raise the event.\nHere is an example with a button and a script that raises the event when the button is pressed.\n\n![ButtonEventRaise](https://i.imgur.com/oBsLpWp.png)\n\nYou can just add a public GameEvent variable to your code and do \n```c#\neventName.Raise(); \n```\nwherever you need.\nNext, you need to add an Event Listener to the object that needs to \"listen\" for an event to be raised.\n\n[!eventRaised](https://i.imgur.com/GyaLgKh.png)\n\nAdd an element to the list (it will default to 0). \nSet the Game Event to listen for by dragging the game event into the slot or clicking on the Game Event variable and finding it in your project.\nYou can listen out for different types of events. You can pass in strings, ints, floats, and bools by setting them in the game event or by setting them before calling the \"eventName.Raise\".\nExample:\n```c#\neventName.sentInt = 5;\n\neventName.Raise();\n```\nThis can then be used with the event type \"Respone For Sent Int\" as long as your function takes in an int as a parameter.\n\nThat's it really.\nCheck out the sample.\n\nDownload Game Event System Demo to see this in action.\nOur example game development scenario includes a player inside a game world, some UI, and a game object for keeping keyboard input separate.  \n\n![sample](https://i.imgur.com/ludHm1p.png)\n\nYeah, it's basic. \nHere is what the scene looks like:\n\n![scene](https://i.imgur.com/xDCTJNJ.png)\n\nI kept Input as it's own object to show how modular this system really is.\nYou don't NEED to have the player on screen to send events the keys were pressed for raising the moving events.\nYou can use WASD to move. You can even hide and show the player using the buttons on screen.\n\nYou will notice the HP bar does nothing. This is intentional.\nIf you go into the \"Game Events\" folder you will see 2 events for Damage and Heal.\n\n![damage](https://i.imgur.com/WyEqd3l.png)\n\nUsing the custom inspector we can raise the event right from viewing the actual event asset. This is great for debugging and quicking checking if an event is firing.\nYou will also notice the sent int is 1. This is the damage to the HP.\nThe HP bar has a simple script for filling the bar by having a current value and max value and converting that to a value the fill image can understand.\nTry damage and heal the player from the editor's events.\n\n\nIf you found any of that confusing, watch MY video above or reach out to me on Twitter: https://twitter.com/stephenmcvicker\n\n## Remember\n\nThe goal is to keep everything modular/data-driven and designer-friendly. \nYou will need to create some helper scripts at some points.\nThis is designed so you can add features or subtract them without breaking anything.\nTry to keep your event listeners to parent objects of the objects you want to affect. If your game object is disabled it won't raise the event so use your parents! \nOn your event raised you can add a listener to display/update UI, spawn in an object or effect, play an animation or even play a sound. There is a lot you can do with this system if you just experiment and play with it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmcvicker%2Funity-scriptableobjects-game-events-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenmcvicker%2Funity-scriptableobjects-game-events-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmcvicker%2Funity-scriptableobjects-game-events-/lists"}