GlobalGameObjectWithComponentCacheBase<T>

class GlobalGameObjectWithComponentCacheBase : GlobalGameObject

A GlobalVariable representing a GameObject, including a set of cached components. This comes very close to what is often referred to as a "singleton" in Unity terminology, but without the disdvantages of actual static code.

Properties

componentCache : T

A set of cached components for direct access.

onChangeComponentCache : SodaEvent<T>

This event is invoked when the GameObject value changes. Instead of passing the GameObject, this event passes the component cache.

value : GameObject

The value this GlobalVariable represents. Throws an exception if you pass a GameObject that doesn't match the component specifications.

Methods

bool TrySetValue(GameObject gameObject)

Tries to set the value to the passed GameObject. It's the same as setting the value, but returns false instead of raising an exception if it fails.