Unity Atoms

Unity Atoms

  • Installation
  • Tutorials
  • Github

›Basics

Introduction

  • Installation
  • Philosophy
  • Overview
  • Preferences
  • FAQ

Tutorials

    Basics

    • Creating Atoms
    • Variables
    • Events
    • Listeners
    • Actions
    • Mono Hooks

    Intermediate

    • Variable Pre Change Transformers
    • Variable Instancer
    • Event Instancer
    • Generator
    • Conditions

    Advanced

    • Advanced example
    • Usage with UniRX

Subpackages

  • Base Atoms
  • FSM
  • Input System
  • Mobile
  • Mono Hooks
  • Scene Mgmt
  • Tags
  • UI

Mono Hooks

Mono Hooks save the effort of writing boilerplate code to raise Atoms Events from Unity's Event Functions.

A great use for Mono Hooks in our example would allow us to remove the Harmful.cs script created earlier. We could instead attach a OnTrigger2DHook.cs to the Harmful GameObject and toggle on Trigger On Enter like this:

mono-hooks-trigger-2d

We could then create a Collider2DAction called DecreasePlayersHealth.cs and add it to a Collider2D Event Reference Listener attached to the Harmful GameObject:

    public class DecreasePlayersHealth : Collider2DAction
    {
        public override void Do(Collider2D collider)
        {
            if (collider.tag == "Player")
            {
                collider.GetComponent<PlayerHealth>().Health.Value -= 10;
            }
        }
    }

mono-hooks-listener

There is much less code written and the responses can be edited in the Editor.

That is it! We have covered the most fundamental pieces of Unity Atoms and a way to use them with Unity's built-in functionality. You can get far with these alone, but there are many more features in Unity Atoms and the subpackages to explore.

← ActionsVariable Pre Change Transformers →
Unity Atoms
Docs
InstallationTutorialsSubpackages
Community
DiscordGitter
More
BlogGitHubStar
Copyright © 2023 Adam Ramberg