{"id":14960700,"url":"https://github.com/grim-/unityobjectactionsystem","last_synced_at":"2025-10-24T19:30:18.347Z","repository":{"id":129859501,"uuid":"329457931","full_name":"Grim-/UnityObjectActionSystem","owner":"Grim-","description":"A ScriptableObject based action System for Unity, add simple interactions to your project.","archived":false,"fork":false,"pushed_at":"2021-02-16T18:39:46.000Z","size":47712,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-22T11:30:26.846Z","etag":null,"topics":["unity3d","unity3d-editor"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Grim-.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2021-01-13T23:35:24.000Z","updated_at":"2023-12-20T06:01:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"b468b88b-80d3-4e86-8b78-3130d56f8a3a","html_url":"https://github.com/Grim-/UnityObjectActionSystem","commit_stats":{"total_commits":39,"total_committers":2,"mean_commits":19.5,"dds":0.1282051282051282,"last_synced_commit":"55b42f7dae6452c73c35977360c777660afa65aa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grim-%2FUnityObjectActionSystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grim-%2FUnityObjectActionSystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grim-%2FUnityObjectActionSystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Grim-%2FUnityObjectActionSystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Grim-","download_url":"https://codeload.github.com/Grim-/UnityObjectActionSystem/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867815,"owners_count":16554365,"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":["unity3d","unity3d-editor"],"created_at":"2024-09-24T13:22:47.801Z","updated_at":"2025-10-24T19:30:17.896Z","avatar_url":"https://github.com/Grim-.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UnityObjectActionSystem\n\nObject Action System is a ScriptableObject based action system, allowing you to drag and drop actions, or a collection of actions to be performed in response to an event.\n\nObjectActionSystem uses DoTween for tweening. http://dotween.demigiant.com/\n\n## What it's For \n\nOAS is designed to be a simple drag, drop and tweak collection of Components, Editors, Scripts and ObjectActions allowing you to quickly add simple interactive elements and objects to your game and/or project. \n\nFrom simple examples such as, playing a particle effect on left clicking a GameObject, or scaling the object up.\n\n\u003cimg src=\"https://i.imgur.com/rmVfad4.gif\"\u003e\n\nOr Starting a fire \n[Burning Barrels Example on Imgur](https://imgur.com/WIaHxtK)\n\n\u003cimg src=\"https://i.imgur.com/ACW14x6.mp4\"\u003e\n\nLets take a quick look at the Element_ActionController for the burning barrels example..\n\nThis is how a typical reaction might look for the Element_ActionController, it takes the element that triggers it, and then a list of actions to execute.\n\n\u003cimg src=\"https://i.imgur.com/AmSAmtw.png\"\u003e\n\nIf you switch an action to the data tab, you can see what data it will use to perform it's actions.\n\n\u003cimg src=\"https://i.imgur.com/mY4qIXi.png\"\u003e\n\n1. SpawnPrefab - This spawns the fire particle system with a 30 second timer component on the prefab, after which the fire will destroy itself.\n2. WaitForRandomRange - Wait For a time randomly picked between WaitMin and WaitMax\n3. SetAffector - Sets this object's Affector component element to the chosen Element scriptable object, allowing the Object to now trigger *other* objects Fire reactions.\n4. WaitFor - Waits For 5 seconds\n5. LerpShaderGraphFloatValue - This action Lerps the PropertyName value to the chosen Value over LerpTime. For this example I created a simple dissolve shader and exposed the \"DissolveValue\" property in order to make the barrels fade out.\n6. DestroyGameObject - You can set either SELF or TARGET as the target of this action, most actions default to SELF.\n\n## So What actions are available? \nCurrently there are only a small selection of actions available, of which over the coming weeks I will list and document, but you can expect most methods from common Components to be added, for now you can check the Actions folder!\n\nThat being said, it is easy to implement your own custom ObjectAction.\n\n1. Extend From *ObjectAction* then override *Init* to add default values if they are needed, it's important to note, these are default values, that are used by the custom editor to dictate how the data tab is displayed, the actual values used are the ones you set in the inspector, but you still need these! \n\nSecondly, Overriding *Execute* is where you write your custom action behaviour using data.GetStringValue(string name), GetFloatValue(string name), GetIntValue(string name), GetVectorValue(string name), GetPrefabValue(string name), GetBoolValue(string name), GetSOValue(string name) to retrieve the values set in the inspector for the action, make sure to *yield break* as the very last thing done!\n\nBelow is how LerpShaderGraphFloatValue is written.\n\n```C#\nusing System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\n\n [CreateAssetMenu(fileName = \"Lerp ShaderGraph Float Value\", menuName = scriptObjectPath + \"Lerp ShaderGraph Float Value\")]\npublic class LerpShadergraphFloatValue : ObjectAction\n{\n    public override void Init()\n    {\n        base.Init();\n        //Adds a Default String Value to the Scriptable Object, that can then be changed in the inspector to suit the particular need by the user.\n        AddDefaultStringValue(\"PropertyName\", \"DissolveValue\");\n        AddDefaultFloatValue(\"Value\", 0f);\n        AddDefaultFloatValue(\"LerpTime\", 1f);\n    }\n\n    public override IEnumerator Execute(BaseController _controller, ActionData data, GameObject target, Vector3 hitpoint)\n    {\n        Renderer targetObject = null;\n        //some actions may target either the object running the controller or the target that triggered it.\n        //You can choose to implement this or not\n        switch (data.targetType)\n        {\n            case ActionData.GameObjectActionTarget.SELF:\n                targetObject = _controller.GetComponent\u003cRenderer\u003e();\n                break;\n            case ActionData.GameObjectActionTarget.TARGET:\n                targetObject = target.GetComponent\u003cRenderer\u003e();\n                break;\n        }\n        //This is one way to retrieve the value set by the user to be used at run time\n        //string PropertyNameToChange = data.GetStringValue(\"PropertyName\");\n        yield return LerpFloatValue(targetObject, data.GetStringValue(\"PropertyName\"), data.GetFloatValue(\"Value\"), data.GetFloatValue(\"LerpTime\"));\n\n\n        yield break;\n    }\n\n\n    private IEnumerator LerpFloatValue(Renderer targetObject, string propertyName, float value, float lerpTime)\n    {\n        float timer = 0;\n        float currentValue = targetObject.material.GetFloat(propertyName);\n\n        while (timer \u003c lerpTime)\n        {\n            timer += Time.deltaTime;\n\n            targetObject.material.SetFloat(propertyName, Mathf.Lerp(currentValue, value, timer / lerpTime));\n\n            yield return null;\n        }\n\n        timer = 0f;\n\n        yield break;\n    }\n}\n```\n\n\n## How do I install and use it?\n\nDownload the Repo and drag the \"Object Action System\" folder into your project, you will need to also install DoTween (Which is excellent), if you don't already have it! \n\nOnce everything is imported and ready - \n\nAdd a __EventMachine__ to an Object followed by an __ActionController__, once this is done add an event from the list of __EventMachine__ events that you want to fire on, drag the Object you want to react into the object slot then in the function drop down, select the ActionController and then which kind of reaction method you wish to call.\n\n\n\n\u003cimg src=\"https://i.imgur.com/EKIE0zH.gif\"\u003e\n\n__*StartNamedReaction(string name)*__\n\nIf you want to call a particular named reaction this is useful for object which have multiple similar but different events, such as a light, which may have a reaction to Toggle Lights on/off, but another two reactions specifically for TurningOff the light and TurningOn respectively. \n\nYou may want the light to toggle on when it is clicked, but you may also want a button that can turn off all attached lights and another to turn them back on. So you would have three reactions \"Toggle\", \"TurnOn\" and \"TurnOff\".\n\nYou must pass the name of the reaction you wish to start in the inspector.\n\n\n\n\u003cimg src=\"https://i.imgur.com/KahlwLL.gif\"\u003e\n\n__*StartReaction*__\n\nA much simpler method for when an object will have only one reaction, this dynamically passes variables to StartReaction(GameObject target, Vector3 hitPosition, Collider targetCollider), this always calls the first reaction in the list.\n\n## How it Works\n\nThe ObjectActionSystem (OAS) is made up of two main parts, a __EventMachine__ and a __ActionController__, there is also a custom Editor for the ActionControllers to make designing new reactions more pain free than through the standard unity UI.\n\nBarrel Example Running\n\u003cimg src=\"https://i.imgur.com/M1e7ety.png\"\u003e\n          \n__EventMachine__\n\nThis handles the calling of events, there are 3 types of EventMachines so far, with most using unity's built-in tag system for filtering events. \n\n\n__EventMachine__\n\n\u003cimg src=\"https://i.imgur.com/PYKybPT.png\"\u003e\n\nThis is the most basic EventMachine it handles Trigger events and Collider events, it also has a __allowedTags__ array field allowing you to specify which Unity tags can trigger events.\n\nEvents For __EventMachine__\n\n*Triggers :*\n\n1. OnEnterTrigger\n2. OnStayTrigger\n3. OnExitTrigger\n\n*Colliders :*\n1. OnEnterCollision\n2. OnStayCollision\n3. OnExitCollision\n\n\n __Mouse_EventMachine__\n\nAn EventMachine for handling GameObject Mouse events, like the __EventMachine__ it has a __allowedTags__ field.\n\nEvents For __Mouse_EventMachine__\n\n1. OnMouseAsButton \n2. OnDragMouse \n3. OnEnterMouse\n4. OnExitMouse\n5. OnUpMouse\n6. OnDownMouse\n7. OnOverMouse\n\n__Element_EventMachine__\n\nThis EventMachine requires the GameObject to also have the Affector Component, it fires an event when another trigger collider enters it own trigger collider, who's Affector it has a reaction for.\n\nEvents For __Element_EventMachine__\n\n1. OnAffector : When another Trigger collider enters the __EventMachine__'s GameObject, with an Affector element for which there is a defined reaction. \n\n\n__ActionController__\n\nThe Controllers come in two different types, the __ActionController__ and __ElementActionController__, these handle the execution and storing of per-object data for the actions.\n\n\u003cimg src=\"https://i.imgur.com/z2fNjCf.png\"\u003e\n\n1. __ActionController\n\nThe __ActionController__ is the default controller, it's provides two functions to call from the EventMachine events\n\n 1. *StartNamedReaction(string name)* - Finds a reaction by it's name then executes it.\n\n 2. *StartReaction* - Executes the first reaction in it's list, regardless of name.\n \n 2. __Element_ActionController__ is the second type of controller, identical to the first except in that, this one uses reactions defined by \"Element\" (ScriptableObject) instead of string names.\n\n\n### TO DO\n1. Custom Editor For the Event Machines!\n2. More Actions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrim-%2Funityobjectactionsystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrim-%2Funityobjectactionsystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrim-%2Funityobjectactionsystem/lists"}