Ejemplo n.º 1
0
    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);
            }
        }
    }
Ejemplo n.º 2
0
    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);
     }
 }
Ejemplo n.º 4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 5
0
 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));
     }
 }
Ejemplo n.º 6
0
    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));
        }
    }
Ejemplo n.º 7
0
    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));
        }
    }