Unity Instantiante inside onReceiveObject handler Error

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
frcol
Posts: 99
Joined: 22 Aug 2010, 09:26
Location: Brazil
Contact:

Unity Instantiante inside onReceiveObject handler Error

Postby frcol » 07 May 2014, 21:43

If I try to Instantiate a GameObject inside the onReceiveObject handler, it gives me a error.

INTERNAL_CALL_Internal_InstantiateSingle can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

Code: Select all

void HandlerObjectReceived (SFSObject obj, User sender)
   {
             Bola bola = Instantiate(bolaInstance, pos, Quaternion.identity) as Bola;
        }


Any help?
Fabio Colombini
Brazil
User avatar
frcol
Posts: 99
Joined: 22 Aug 2010, 09:26
Location: Brazil
Contact:

Re: Unity Instantiante inside onReceiveObject handler Error

Postby frcol » 09 May 2014, 19:36

Nobody knows a way to do that?

I´m using a Class field as flag for the Update to instantiate the GameObject.
So, when I receive an onReceiveObject, I set the flag as TRUE and the Update will Instantiate and set the flag as FALSE.

I don´t think it´s the best way, but worked.
Fabio Colombini
Brazil

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 74 guests