Skip to content

Instantly share code, notes, and snippets.

@Naxum
Last active August 29, 2015 14:01
Show Gist options
  • Save Naxum/f9ff6bdff1fd12b46b72 to your computer and use it in GitHub Desktop.
Save Naxum/f9ff6bdff1fd12b46b72 to your computer and use it in GitHub Desktop.
Simple custom Unity references with caching
using UnityEngine;
using System.Collections;
public class NaxBehaviour : MonoBehaviour
{
private PathFinder _pathFinder;
public PathFinder pathFinder
{
get
{
if (_pathFinder == null)
{
PathFinder finder = GetComponent<PathFinder>();
this.pathFinder = finder;
}
return this._pathFinder;
}
set
{
this._pathFinder = value;
SendMessage("SetPathFinder", _pathFinder, SendMessageOptions.DontRequireReceiver);
}
}
private void SetPathFinder(PathFinder finder)
{
this._pathFinder = pathFinder;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment