Created
October 16, 2012 15:32
-
-
Save henkboom/3900007 to your computer and use it in GitHub Desktop.
Data that expires on scene close. (Unity)
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.Generic; | |
// Data that expires on scene close. | |
// Pretty much a hack, there must be a better way! | |
class SceneData<T> where T : class | |
{ | |
GameObject go; | |
T data; | |
public T Value | |
{ | |
get | |
{ | |
return go == null ? null : data; | |
} | |
set | |
{ | |
if(go == null) | |
{ | |
go = new GameObject("SceneDataDummy"); | |
go.hideFlags = HideFlags.HideInHierarchy; | |
} | |
data = value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment