Skip to content

Instantly share code, notes, and snippets.

@henkboom
Created October 16, 2012 15:32
Show Gist options
  • Save henkboom/3900007 to your computer and use it in GitHub Desktop.
Save henkboom/3900007 to your computer and use it in GitHub Desktop.
Data that expires on scene close. (Unity)
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