Beispiel #1
0
    public static BrainCloudWrapper GetInstance()
    {
        if (s_applicationIsQuitting)
        {
            return(null);
        }

        lock (s_lock)
        {
            if (s_instance == null)
            {
                s_instance = (BrainCloudWrapper)FindObjectOfType(typeof(BrainCloudWrapper));
                if (s_instance != null)
                {
                    s_instance.Reauthenticate();
                }

                if (FindObjectsOfType(typeof(BrainCloudWrapper)).Length > 1)
                {
                    Debug.LogError("[Singleton] Something went really wrong " +
                                   " - there should never be more than 1 singleton!" +
                                   " Reopenning the scene might fix it.");
                    return(s_instance);
                }

                if (s_instance == null)
                {
                    GameObject go = new GameObject(GAMEOBJECT_BRAINCLOUD);
                    s_instance = go.AddComponent <BrainCloudWrapper>();
                    DontDestroyOnLoad(go);
                }
            }
            return(s_instance);
        }
    }
Beispiel #2
0
    public static BrainCloudWrapper GetInstance()
    {
        if (!BrainCloudClient.EnableSingletonMode)
#pragma warning disable 162
        {
            throw new Exception(BrainCloudClient.SingletonUseErrorMessage);
        }
#pragma warning restore 162

        if (_applicationIsQuitting)
        {
            return(null);
        }
        if (_instance == null)
        {
#if !DOT_NET
            _instance = (BrainCloudWrapper)FindObjectOfType(typeof(BrainCloudWrapper));
            if (_instance != null)
            {
                _instance.Reauthenticate();
            }

            if (FindObjectsOfType(typeof(BrainCloudWrapper)).Length > 1)
            {
                Debug.LogError("[Singleton] Something went really wrong " +
                               " - there should never be more than 1 singleton!" +
                               " Reopening the scene might fix it.");
                return(_instance);
            }

            if (_instance == null)
            {
                GameObject go = new GameObject(GAMEOBJECT_BRAINCLOUD);

                _instance = go.AddComponent <BrainCloudWrapper>();
#pragma warning disable 618
                _instance.Client = BrainCloudClient.Get();
#pragma warning restore 618

                DontDestroyOnLoad(go);
            }
#else
            _instance = new BrainCloudWrapper(BrainCloudClient.Get());
#endif
            _instance.LoadData();
        }
        return(_instance);
    }
    public static BrainCloudWrapper GetInstance()
    {
        if (s_applicationIsQuitting)
        {
            return null;
        }

        lock (s_lock)
        {
            if (s_instance == null)
            {

                s_instance = (BrainCloudWrapper) FindObjectOfType(typeof(BrainCloudWrapper));
                if (s_instance != null)
                {
                    s_instance.Reauthenticate();
                }

                if ( FindObjectsOfType(typeof(BrainCloudWrapper)).Length > 1 )
                {
                    Debug.LogError("[Singleton] Something went really wrong " +
                        " - there should never be more than 1 singleton!" +
                        " Reopenning the scene might fix it.");
                    return s_instance;
                }

                if (s_instance == null)
                {
                    GameObject go = new GameObject(GAMEOBJECT_BRAINCLOUD);
                    s_instance = go.AddComponent<BrainCloudWrapper>();
                    DontDestroyOnLoad(go);
                }
            }
            return s_instance;
        }
    }