示例#1
0
        public void submitScore(Action <bool, string> callback)
        {
            submitScoreCallback = callback;
            string gameObjectName = "OpenKitSubmitScoreObject." + DateTime.Now.Ticks;

            callbackGameObjectName = gameObjectName;


            // Create a new OKScore gameobject (called scoreComponent) and give it a unique name
            // This allows us to track unique score submission requests and handle
            // async native code

#if !UNITY_EDITOR
            GameObject gameObject = new GameObject(gameObjectName);
            DontDestroyOnLoad(gameObject);

            OKScore scoreComponent = gameObject.AddComponent <OKScore>();
            scoreComponent.submitScoreCallback = callback;

            scoreComponent.scoreValue             = scoreValue;
            scoreComponent.OKLeaderboardID        = OKLeaderboardID;
            scoreComponent.displayString          = displayString;
            scoreComponent.metadata               = metadata;
            scoreComponent.callbackGameObjectName = gameObjectName;

            OKManager.SubmitScore(scoreComponent);
#endif
        }
示例#2
0
        public void SubmitScoreNatively(Action <bool, string> callback)
        {
            if (MetadataBuffer != null)
            {
                UnityEngine.Debug.LogError("A score with MetadataBuffer set cannot be submitted via native plugin");
                callback(false, null);
            }

            // Create a uniquely named GameObject, and keep it around between scene switches.
            string     gameObjectName = "OpenKitSubmitScoreObject." + DateTime.Now.Ticks;
            GameObject gameObject     = new GameObject(gameObjectName);

            UnityEngine.Object.DontDestroyOnLoad(gameObject);

            OKScoreSubmitComponent scoreSubmitComponent = gameObject.AddComponent <OKScoreSubmitComponent>();

            scoreSubmitComponent.submitScoreCallback    = callback;
            scoreSubmitComponent.callbackGameObjectName = gameObjectName;
            scoreSubmitComponent.scoreValue             = scoreValue;
            scoreSubmitComponent.OKLeaderboardID        = LeaderboardID;
            scoreSubmitComponent.displayString          = displayString;
            scoreSubmitComponent.metadata = metadata;
            scoreSubmitComponent.gameCenterLeaderboardCategory = gameCenterLeaderboardCategory;

            OKManager.SubmitScore(scoreSubmitComponent);
        }