I use the "call method advanced" PM action to call all my analytics events that are in a C# script from Playmaker FSM actions often that reside in templates.
I create a global obj variable of the C# script on start- and use that global var to call the events from various game objects, often templates. This all works perfectly when I pass strings as parameters to the C# script for the analytic event names.
Yesterday- in an attempt to avoid typos, I switched the parameter of the C# script method from a string to an enum list. The Call Method advanced action very nicely displays my enum list as a drop down list within the action - slick! But after setting the correct enum in the Call Method Advanced action, at runtime it will switch to the first item in the enum list instead of retaining the one I set. Is this something to do with reflection, or global obj variables that I don't understand? Any one come across this?
code snippet of the c# script I am calling, works fine when a string is used instead of the enum list:
public enum playerIAP_EventsEnum
{
IAP_ButtonPress,
IAP_PurchaseSuccess,
IAP_PurchaseFail,
IAP_BankOpened,
IAP_BankClosed,
IAP_SpecialOfferDisplayed,
IAP_SpecialOfferClosed
}
public void PlayerIAP_Events(playerIAP_EventsEnum EventName, string IAP_ID, float IAP_Price, int Level, string TransactionContext)
{
var request = new WriteClientPlayerEventRequest();
string success = "Successful PFab Event";
string FSM_Event = "success";
#if UNITY_ANALYTICS
StoreType storeType = StoreType.Premium;
switch (EventName)
{
case playerIAP_EventsEnum.IAP_ButtonPress :
AnalyticsEvent.StoreItemClick(storeType, IAP_ID, null, new Dictionary<string, object>
{
{ "level", Level },
{ "price", IAP_Price }
});
break;
case playerIAP_EventsEnum.IAP_BankOpened:
AnalyticsEvent.StoreOpened(storeType, new Dictionary<string, object>
{
{ "level", Level }
});
break;
case playerIAP_EventsEnum.IAP_PurchaseSuccess:
AnalyticsEvent.IAPTransaction(TransactionContext, IAP_Price, IAP_ID, null, Level.ToString(), null, null);
break;
default:
AnalyticsEvent.Custom(EventName.ToString(), new Dictionary<string, object>
{
{ "level", Level },
{ "iap_id", IAP_ID }
});
break;
}
#endif
#if PLAYFAB
if (IsClientLoggedIn())
{
eventData = new Dictionary<string, object>()
{
{"iap_id", IAP_ID},
{"iap_price", IAP_Price},
{"level", Level},
};
request.Body = eventData;
request.EventName = EventName.ToString();
PlayFabClientAPI.WritePlayerEvent(request, result =>
{
RaiseCallbackSuccess(success, PlayFabAPIMethods.WritePlayerEvent, MessageDisplayStyle.none, FSM_Event);
}, PlayFabErrorCallback);
}
else { Debug.Log("UserCustomEvents.cs --- Playfab not logged in, won't send this event: " + EventName); }
#endif
#if FIREBASE_ENABLED // START FIREBASE ANLYTICS EVENT!!!!============================================================================----------------------------------------------
Firebase.Analytics.Parameter[] iap_parameters = {
new Firebase.Analytics.Parameter( "iap_id", IAP_ID)
new Firebase.Analytics.Parameter( "iap_price", IAP_Price)
new Firebase.Analytics.Parameter( "level", Level)
};
Firebase.Analytics.FirebaseAnalytics.LogEvent(EventName, iap_parameters);
#endif // END FIREBASE ANLYTICS EVENT!!!!============================================================================-------------------------------------------------
// START FACEBOOK EVENT!!!!============================================================================
var fb_ae_parameters = new Dictionary<string, object>();
fb_ae_parameters["iap_id"] = IAP_ID;
fb_ae_parameters["iap_price"] = IAP_Price;
fb_ae_parameters["level"] = Level;
FB.LogAppEvent(EventName.ToString(), parameters: fb_ae_parameters);
// End FACEBOOK EVENT!!!================================================================================
if (debugLogEnabled) Debug.Log("PF and FB app events sent: " + EventName + " iap_id" + IAP_ID + " iap_price: " + IAP_Price + " level: " + Level + " TransactionContext: " + TransactionContext);
}
Thanks in advance.