Hello,
DBM_clearDatabaseVariables.js
static var instance : DBM_clearDatabaseVariables;
// This is where the magic happens.
// FindObjectOfType(âŚ) returns the first AManager object in the scene.
instance = FindObjectOfType(DBM_clearDatabaseVariables);
if (instance == null)
{
Debug.Log (âCould not locate an DB_Manager object. You have to have exactly one DB_Manager in the scene.â);
}
// Ensure that the instance is destroyed when the game is stopped in the editor.
function OnApplicationQuit()
{
instance = null;
}
function clearDatabaseVariables()
{
var loadingText : GameObject;
loadingText = GameObject.Find(âLoading_Textâ);
loadingText.guiText.text = âClearingâŚâ;
// Global_Variables.mySubscriptions.Clear();
// Global_Variables.curriculaItems.Clear();
// Global_Variables.cameraItems_names.Clear();
// Global_Variables.cameraItems_tx.Clear();
// Global_Variables.cameraItems_ty.Clear();
// Global_Variables.cameraItems_tz.Clear();
// Global_Variables.cameraItems_rx.Clear();
// Global_Variables.cameraItems_ry.Clear();
// Global_Variables.cameraItems_rz.Clear();
// Global_Variables.cameraItems_sx.Clear();
// Global_Variables.cameraItems_sy.Clear();
// Global_Variables.cameraItems_sz.Clear();
// Global_Variables.cameraItems_orthoScale.Clear();
// Global_Variables.mySubscriptions.Clear();
// Global_Variables.curriculaItems.Clear();
// Global_Variables.menuItems.Clear();
}
Startup Object in my scene
function Awake ()
{
Application.targetFrameRate = 15;
new GameObject(âDBM_clearDatabaseVariablesâ).AddComponent(âDBM_clearDatabaseVariablesâ);
// new GameObject(âDBM_getActiveSubscriptionâ).AddComponent(âDBM_getActiveSubscriptionâ);
// new GameObject(âDBM_getMySubscriptionsâ).AddComponent(âDBM_getMySubscriptionsâ);
// new GameObject(âDBM_getUserCurriculaâ).AddComponent(âDBM_getUserCurriculaâ);
// new GameObject(âDBM_getUserCurriculaMenusâ).AddComponent(âDBM_getUserCurriculaMenusâ);
// new GameObject(âDBM_getCameraPositionsâ).AddComponent(âDBM_getCameraPositionsâ);
// new GameObject(âDBM_getUserInfoâ).AddComponent(âDBM_getUserInfoâ);
}
function Start()
{
var loadingText : GameObject;
loadingText = GameObject.Find(âLoading_Textâ);
Time.timeScale = 1;
//CLEAR DATABASE VARIABLES
DBM_clearDatabaseVariables.instance.clearDatabaseVariables();
// //GET THE SELECTED SUBSCRIPTION
// DBM_getActiveSubscription.instance.getActiveSubscription();
// //SET ASSET URL
// Global_Variables.assetsURL = (Global_Variables.dataBank + Global_Variables.activeSubscription + â/â);
// //GET MY SUBSCRIPTIONS
// DBM_getMySubscriptions.instance.getMySubscriptions();
// //GET CURRICULA
// DBM_getUserCurricula.instance.getUserCurricula();
// //GET CURRICULA Menus
// DBM_getUserCurriculaMenus.instance.getUserCurriculaMenus();
// //GET DEFAULT CAMERAS
// DBM_getCameraPositions.instance.getCameraPositions();
// //GET USER INFORMATION
// DBM_getUserInfo.instance.getUserInfo();
loadingText.guiText.text = âLoading PlayerâŚâ;
//Application.LoadLevel(âMainProgram_1.0â);
Application.LoadLevel(âTestâ);
}
How do i âproperlyâ execute a singleton from a function Start without getting a ref obj error?
Any help appreciated.
Thanks,
Oliver