Last active
August 29, 2015 14:01
-
-
Save Naxum/f9ff6bdff1fd12b46b72 to your computer and use it in GitHub Desktop.
Simple custom Unity references with caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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