CustomAssets
Askowl Custom Assets
Trigger.cs
1 // With thanks to Ryan Hipple -- https://github.com/roboryantron/Unite2017
2 
3 using System;
4 using Askowl;
5 using UnityEngine;
6 
7 namespace CustomAsset.Mutable {
8  /// <a href="http://bit.ly/2RlCfFy">Dynamic custom asset without any values. Use it to trigger and listen to events</a> <inheritdoc />
9  [CreateAssetMenu(menuName = "Custom Assets/Trigger")]
10  public class Trigger : WithEmitter {
11  /// <a href="http://bit.ly/2RlCfFy">Retrieve a loaded instance of a named trigger</a>
12  public static Trigger Instance(string name) {
13  Trigger instance = Objects.Find<Trigger>(name);
14  if (instance != null) return instance;
15 
16  instance = CreateInstance<Trigger>();
17  instance.name = Guid.NewGuid().ToString();
18  return instance;
19  }
20 
21  /// <a href="http://bit.ly/2RlCfFy">Call to fire off a Changed event, since we have no data to change...</a>
22  public virtual void Fire() => Emitter.Fire();
23  }
24 }
Typeless base class that has an emitter
static Trigger Instance(string name)
Retrieve a loaded instance of a named trigger
Definition: Trigger.cs:12
virtual void Fire()
Call to fire off a Changed event, since we have no data to change...
Dynamic custom asset without any values. Use it to trigger and listen to events
Definition: Trigger.cs:10