Announcements
The Scaleform forum is now read-only. Please head to the Gamedev site for product support.
Scaleform Forum (Read Only)
Scaleform enables developers to leverage the power of the Adobe® Flash® tool set to create powerful user interface environments for video games.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ExternalInterface.call issue

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
904 Views, 5 Replies

ExternalInterface.call issue

Hello,

we are still evaluating Scaleform for Unity and we've found some issues with the ExternalInterface.call function.
Sometimes C# do not receiving the call. And the only way to fix it, is to wait for the next frame in AS3.

Also, if you execute ExternalInterface.call more than 8 times in one frame, Scaleform crashes on device and in Editor.

Is any of this a known bug?
5 REPLIES 5
Message 2 of 6
MatthewDoyleArt
in reply to: Anonymous

I have not seen this issue before, but someone from support may have some info or advice. I'll let them know. If you can provide an example that causes the issue, that would be helpful.

Matthew Doyle
Technical Marketing Manager

-----------------------------

Area Blog: Game Dev Blog
Watch me on Youtube: Youtube.com/MatthewDoyleArt
Check out some of my work at: MatthewDoyle.com
Message 3 of 6
Anonymous
in reply to: Anonymous

I took a look at DarthIwan's code and this is what happens:

UNITY C#: Invoke("doSomething")
SCALEFORM: function doSomething
... flash stuff ...
ExternalInterface.Call("RegisterMovie", ...)
ExternalInterface.Call("OnSomethingFinished")

<next frame>

UNITY C#: SFManager.ProcessCommands
int numCommands = Marshal.ReadInt32(pCommandOffset);
...
for (int i = 0; i < numCommands; i++)
...
OnExternalInterface(movieID, "OnSomethingFinished", pargs, numArgs, sfValueSize)
... will call OnSomethingFinished in C# ...

<still in SFManager.ProcessCommands>

UNITY C#: OnSomethingFinished
Invoke("doAnotherThing")
SCALEFORM: doAnotherThing
... flash stuff ...
ExternalInterface.Call("TheLostCallback", ...)

<back in SFManager.ProcessCommands>

UNITY C#: SFManager.ProcessCommands
... finished handling commands ...
SF_ClearCommandBuffer(numCommands);

<finished processing queued external calls>


and the TheLostCallback gets lost


So my wild guess is:

Calling ExternalInterface during the execution
of another ExternalInterface call (ProcessCommands running) adds the call to shared buffer
but at the end of the outer ExternalInterface call the buffer gets cleared and the call gets lost.
Message 4 of 6
MatthewDoyleArt
in reply to: Anonymous

Ah I see. It seems like too many ExternalInterface callbacks happening too close together. Perhaps there is a better way of handling this. What is the second Invoke ("doAnotherThing") doing? Is it really necessary to have these functions in ActionScript? Can they be moved to C#, where the DirectAccess API can be used to modify Flash display objects?

Matthew Doyle
Technical Marketing Manager

-----------------------------

Area Blog: Game Dev Blog
Watch me on Youtube: Youtube.com/MatthewDoyleArt
Check out some of my work at: MatthewDoyle.com
Message 5 of 6
am964
in reply to: Anonymous

Hi Darthiwan-

You are correct in reporting that nested externalinterface callbacks could be an issue. The root of this problem is that on iOS, C# delegates are not supported, meaning that it's not possible to call a C# function directly from the plugin. This restriction forced us to implement the command buffer method, which unfortunately introduces a one frame latency in processing the external interface callbacks since the callbacks will be processed in the next game update.

We might revisit this issue later, however I think for now you can restructure your UI logic to avoid nested external interface calls. As Matthew points out, using direct access API is an effective and fast way to do script-AS communication.

Thanks,
Ankur
Message 6 of 6
Anonymous
in reply to: am964

Hi Ankur,

thank you for your answer. We have this issue with Android and OSX as well.
But the tip with direct access API was great, thank you both.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report