コード例 #1
0
ファイル: T4_Singleton.cs プロジェクト: Fallshadow/-
    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);
            }
        }
    }
コード例 #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);
            }
        }
    }
コード例 #3
0
 void OnEnable()
 {
     if (null == instance)
     {
         s_Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
コード例 #4
0
ファイル: SingletonGameObject.cs プロジェクト: gewl/manticore
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #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));
     }
 }
コード例 #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));
        }
    }
コード例 #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));
        }
    }