public static void CreateInstance() { if (s_instance != null) { return; } GameObject singletonObject = SingletonGameObject.getObject(); if (singletonObject == null) { return; } DontDestroyOnLoad(singletonObject); T[] objList = GameObject.FindObjectsOfType(typeof(T)) as T[]; if (objList.Length == 0) { singletonObject.AddComponent <T>(); } else if (objList.Length > 1) { //act.debug.PrintSystem.Log("You have more than one " + typeof(T).Name + " in the scene. You only need 1, it's a singleton!"); foreach (T item in objList) { Destroy(item); } } }
public static void CreateInstance() { if (s_instance != null) { return; } GameObject singletonObject = SingletonGameObject.getObject(); if (singletonObject == null) { return; } DontDestroyOnLoad(singletonObject); T[] objList = GameObject.FindObjectsOfType(typeof(T)) as T[]; if (objList.Length == 0) { singletonObject.AddComponent <T>(); } else if (objList.Length > 1) { foreach (T item in objList) { Destroy(item); } } }
void OnEnable() { if (null == instance) { s_Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
private void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else if (instance != this) { Destroy(gameObject); } }
static int Init(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); SingletonGameObject <UIWindowFirstLoading> obj = (SingletonGameObject <UIWindowFirstLoading>)ToLua.CheckObject <SingletonGameObject <UIWindowFirstLoading> >(L, 1); obj.Init(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int LoadGameObjectByResources(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); UnityEngine.GameObject o = SingletonGameObject <UIWindowFirstLoading> .LoadGameObjectByResources(); ToLua.PushSealed(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int HasInstance(IntPtr L) { try { ToLua.CheckArgsCount(L, 0); bool o = SingletonGameObject <UIWindowFirstLoading> .HasInstance(); LuaDLL.lua_pushboolean(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }