Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using Prime31;
- namespace HutongGames.PlayMaker.Actions
- {
- [ActionCategory("Social/Facebook")]
- [Tooltip("Posts a score for a user")]
- public class PostScore : FsmStateAction
- {
- [RequiredField]
- [Tooltip("Score to submit")]
- public FsmInt score;
- [Tooltip("What event to call on success")]
- public FsmEvent onSuccess;
- [Tooltip("What event to call on error")]
- public FsmEvent onError;
- FsmString socialError;
- public override void Reset()
- {
- }
- public override void OnEnter()
- {
- #if UNITY_ANDROID || UNITY_IOS
- var hasWritePermissions = FsmVariables.GlobalVariables.GetFsmBool("hasWritePermissions").Value;
- if(!hasWritePermissions) {
- socialError = "You must have write permissions to call this function";
- Debug.Log (socialError.Value);
- Fsm.Event(onError);
- Finish();
- return;
- }
- Facebook.instance.postScore(score.Value, PostScoreFinish);
- #else
- Finish ();
- #endif
- }
- public void PostScoreFinish(bool success) {
- Debug.Log ("Post score finished with success: " + success);
- Finish ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement