Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Christoph on July 09, 2022, 10:01:51 AM
-
I know I had this before already, but I'm stuck again and can't find out how to solve it.
But I have this SDK I need to implement (Appsflyer) and am writing my own actions to trigger specific events at given times.
I have a particular problem with this code as seen in the attached screenshot:
AppsFlyeriOS.validateAndSendInAppPurchase("productIdentifier", "price", "currency", "tranactionId", null, this);
The problem lies in "this" which refers to a MonoBehaviour gameObject and the error is:
cannot convert from 'HutongGames.PlayMaker.Actions.AFIAPValidation' to 'UnityEngine.MonoBehaviour'
How can I resolve this (pun intended)?
Edit: can't attach any image because the upload folder is full.
but the method is:
void AppsFlyeriOS.validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
-
oh so I kinda remembered and I think all I have to do is to connect it to a script component that is based on MonoBehaviour. So I'm setting a gameobject variable and a monobehaviour variable, then get the script component on that gambeobject and store it into the monobehaviour variable and call that instead of "this". :D
-
Hi.
You can use a FsmGameObject or FsmOwnerDefault.
IF you use FsmOwnerDefault, then you need to use this line :
var go = Fsm.GetOwnerDefaultTarget(gameObject);
and use go
else use gameObject.Value
-
So what I did is this:
[RequiredField]
[Tooltip("The Game Object the Appsflyer script is attached to")]
public FsmOwnerDefault GameObject;
private MonoBehaviour _monoBehaviourClass;
public override void OnEnter()
{
_monoBehaviourClass = Fsm.GetOwnerDefaultTarget(GameObject).GetComponent<AppsFlyerObjectScript>();
#if UNITY_IOS
//for iOS
AppsFlyeriOS.validateAndSendInAppPurchase("productIdentifier", "price", "currency", "tranactionId", null, _monoBehaviourClass);
#elif UNITY_ANDROID
//for Android
//AppsFlyerAndroid.validateAndSendInAppPurchase( "publicKey", "signature", "purchaseData", "price", "currency", null, _monoBehaviourClass);
#endif
Finish();
}
I'm in the understanding I have to get a c# script based on monobehaviour. What does
var go = Fsm.GetOwnerDefaultTarget(gameObject);
do?