Giter Site home page Giter Site logo

ustableobject's Introduction

uStableObject, when 1 / reacts

Unity3D ScriptableObject based architecture framework.

ScriptableObject based architecture simplify wiring elements and systems together while also bringing the benefits of decoupling. It can also ease sharing data accross scenes in a simple, clean, generic an reliable way.

No more fiddly unappliable cross prefab references in scene objects, everything pings pongs through your defined assets. Never suffer from a broken reference again !

Getting Started

GameEvent

Creating a GameEvent

  • Right click in project, goto Create > uStableObject > GameEvent
  • Choose type and click to create a GameEvent asset

Creating a GameEvent listener as an asset (lives in project)

  • Right click in project, goto Create > uStableObject > GameEvent > AssetListeners
  • Choose matching type and click to create an asset listener
  • Plug the GameEvent in the GameEvent field of the listener
  • Setup the UnityEvent on the listener to trigger desired feature

Creating a GameEvent listener as a MonoBehaviour (lives in scene)

  • Create a GameObject, add a GameEventListener of the matching type (searching "event listener" works well to list all available types)
  • Plug the GameEvent in the GameEvent field of the listener
  • Setup the UnityEvent on the listener to trigger desired feature

Creating a GameEvent listener as a Wrapper (for use from pure C# classes)

  • From your script, call GameEventListenerWrapper.Create(myEvent, myCallback) (a generic version is also available)
  • Keep the reference to the wrapper until done with it
  • When you are done with it, make sure to call eventWrapper.Dispose() to clean things up internally

Firing a GameEvent

  • From a script with a reference to the GameEvent asset, call myGameEvent.Raise();
  • It may eventually expect a parameter depending on choosen type when creating the GameEvent, for example myTransformEvent.Raise(this.transform);

Vars

Vars store data of the specified type, and also act as a GameEvent of that type. For exemple setting myBoolVar.Value = true; will also fire the GameEvent as if calling myBoolVar.Raise(true) on a bool event

Vars work with standard GameEvent listeners, but also have a specific type of listener called Watcher that also fires the value when the object is enabled.

Ordering

Experience using USO tells that when ordering appears to be needed in between listeners to an event, that event isn't specific enough and should be broken in smaller pieces, thus effectively replacing ordering by a better event chain definition.

For example, a StartGame event fired when arriving in the game scene could be split up into SceneFinishedLoading and then StartGame to allow preparing things before actually starting the game.

ustableobject's People

Contributors

instance-id avatar met44 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

instance-id

ustableobject's Issues

Version control

Hi @met44,

Thanks for making this awesome UPM package. I'm the creator of the OpenUPM platform, an open-source UPM registry, and continuous build service based on Git tags. It's hosting more than 200+ open-source UPM packages at the time of writing.

To make it happen, I would suggest you make GitHub releases (which create Git tags) for version control. It can be achieved either manually or using an automatic approach.

After your GitHub release, our build pipelines will detect the changes and build UPM packages in 5-10 minutes. Then you can visit your package at https://openupm.com/packages/com.met44.ustableobject/.

Hopeful this makes sense for you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.