We Recently started porting our unity game from WebGL to mobile. This mostly consisted of UI changes and no changes to the SFS code were made, however we started encountering weird cast errors right away in the client side code.
Code: Select all
InvalidCastException: Cannot cast from source type to destination type.
Sfs2X.Entities.Variables.BaseVariable.GetIntValue ()
BuddyListController.OnBuddyVariablesUpdate (Sfs2X.Core.BaseEvent evt) (at Assets/Scripts/UIScripts/BuddyListController.cs:116)
The Client Side code is as follows:
Code: Select all
private void OnBuddyOnlineUpdate(BaseEvent evt)
{
bool isItMe = (bool)evt.Params["isItMe"];
Buddy buddy = (Buddy)evt.Params["buddy"];
if (!isItMe)
{
if (buddy.IsOnline)
{
Debug.Log(buddy.GetVariable("$userID").Type);
int buddyID = buddy.GetVariable("$userID").GetIntValue();
}
}}
Server side code is:
Code: Select all
buddyVars.add(new SFSBuddyVariable("$userID", res.getSFSObject(i).getLong("user_id").doubleValue()));
the cast error happens when buddy.GetVariable("$userID").GetIntValue(); line is run. this is really confusing since this is working code in the WebGL Build. This is happening in a large amount of places in the code base.