Skip to content

Referencing Futures AND Exposed references at the same time

DDevilISL edited this page Jan 30, 2018 · 1 revision

Now you understand how future and exposed references work, and if you've put them to work, you have probably noticed a small problem:
Sometimes you have a token that works with both of them, but you have to write two different classes, one for future references, and one for exposed references
However, there is a better solution, there is a third special reference that is simply called "Reference". It allows you to work with both futures and exposed references at the same times. They are resolved the exact same was the other two, for example:

public class MyToken : IToken {
    public Reference<GameObject> System;
    public Vector3 Position;

    public IEnumerator Execute(CutscenePlayer player) {
        var systemInScene = System.Resolve(player);
        Object.Instantiate(systemInScene, Position, Quaternion.identity);
        yield break;
    }
}

And here is how they look on the inspector: