Exemple #1
0
    public static void Initialize(string url, string secretKey, string appId, string version)
    {
        BrainCloudWrapper bcw = GetInstance();

        bcw._lastUrl        = url;
        bcw._lastSecretKey  = secretKey;
        bcw._lastAppId      = appId;
        bcw._lastAppVersion = version;
        bcw.Client.Initialize(url, secretKey, appId, version);

        _instance.LoadData();
    }
Exemple #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);
    }
Exemple #3
0
    /// <summary>
    /// Gets the singleton instance of the BrainCloudWrapper.
    /// The BrainCloudWrapper object is stored in a Unity Game Object.
    /// </summary>
    /// <returns>The instance</returns>
    public static BrainCloudWrapper GetInstance()
    {
        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>();
                DontDestroyOnLoad(go);
            }
#else
            _instance = new BrainCloudWrapper();
#endif
            _instance.LoadData();
        }
        return(_instance);
    }