Coder Social home page Coder Social logo

adv-unity-event's Introduction

Advanced Unity Event

Lightweight but more powerful version of Unity Event.

  • Reorderable events
  • Can directly use generic AUEEvent<T> instead of a creating a new class inheriting from UnityEvent
  • Method searcher popup (AddComponent-like)
  • Can use AUEGet<TResult> to create a method's result
  • Supports AOT
  • Supports runtime event subscription (and are displayed in the Inspector)
  • Custom parameters:
    • Constant: support all basics native constants + UnityEngine.Object + custom serializable class
    • Dynamic: allow to select where you pass your method arguments
    • Method: use nested method as parameter
    • Property: use a property or nested property (following a path of properties and fields)
  • Provide some static helpers to use directly in AUE methods for common operation (ie. BoolSH.Invert to invert a boolean value).

Changelog

Dependencies

Minimum version Unity required: 2019.3

Screenshots

Usage

// Create simple event, without arguments
[SerializeField]
private AUEEvent _simpleEvent;

// Create an event that pass an int argument
[SerializeField]
private AUEEvent<int> _intEvent;

 // Supports 4 arguments. Can add more easily.
[SerializeField]
private AUEEvent<int, float, string, Transform> _argEvent;

 // Create a specialized event from inheriting
[Serializable]
public class FloatAdvUnityEvent : AUEEvent<float> { }

[SerializeField]
private FloatAdvUnityEvent _floatEvent;

 // Create a method that will return a float
[SerializeField]
private AUEGet<float> _floatGetter;

// Create a method that will return a string, and allow to pass an int argument.
[SerializeField]
private AUEGet<int, string> _intGetter;

You can even make dynamic customizable AUEEvent. It can be useful to make kind of generic events :

[SerializeField]
private SerializableType _parameterType;

[SerializeField]
private CustomizableAUEEvent _customizableEvent;

private void OnValidate()
{
    if (_parameterType.IsValidType)
    {
    	_customizableEvent.DefineParameterTypes(_parameterType.Type);
    }
}

void Start()
{
    _customizableEvent.Invoke(value); // value must be of the matching type!
}

Advanced

adv-unity-event's People

Contributors

abegue avatar begounet avatar

Stargazers

 avatar

Watchers

 avatar

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.