/// <summary> /// Initialize the LuaStore component. /// This component behaves somewhat like a singleton in that only one instance /// is permitted in the application which persists until shutdown. /// </summary> protected virtual bool Init() { if (initialized) { return true; } if (instance == null) { // This is the first instance of the LuaStore, so store a static reference to it. instance = this; } else if (instance != this) { // This is an extra instance of LuaStore. We only need one in the scene, so delete this one. Destroy(gameObject); return false; } // We're now guaranteed that this instance of LuaStore is the first and only instance. primeTable = DynValue.NewPrimeTable().Table; // DontDestroyOnLoad only works for root objects transform.parent = null; DontDestroyOnLoad(this); initialized = true; return true; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); // Use the Serialization extension to display the contents of the prime table. LuaStore luaStore = target as LuaStore; if (luaStore.PrimeTable != null) { EditorGUILayout.PrefixLabel(new GUIContent("Inspect Table", "Displays the contents of the fungus.store prime table.")); string serialized = luaStore.PrimeTable.Serialize(); EditorGUILayout.SelectableLabel(serialized, GUILayout.ExpandHeight(true)); } }