- Home /
Question by
Noel9386 · Jun 08, 2017 at 08:29 PM ·
c#javascriptwebglhtml
Unity 5.6 not calling function when called from webpage
I have the following function
public void GetStepData(string i)
{
iDisplay.text = i;
print("recived data: " + i);
Debug.Log("recived data: " + i);
string[] iData = i.Split(',');//split the income data for parsing
int numScenes = SceneManager.sceneCountInBuildSettings;//total number of scenes in current build
int scene = 2;//first scene where an html action called a unity scene change
foreach (string s in iData)//go through each entry and create a reference
{
int loweststepNumberforScene = int.Parse(s);
stepNumbers.Add(loweststepNumberforScene);
sceneIndex.Add(scene);
scene++;
}
}
that I call when loading is finished on the UnityProgress.js like so
function UnityProgress(gameInstance, progress)
{
UnityStepData = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27";
if (!gameInstance.Module)
{
return;
}
if (progress == 1)
{
gameInstance.SendMessage("Messenger","GetStepData",UnityStepData);
}
}
I set up the debug, print, and GUI text to indicate that I am getting the string of data that I need to get however it is not updating the GUI text which would be the best place to put it I thought. How should I go about getting this data into unity in a similar way?
Comment
Answer by Noel9386 · Jun 09, 2017 at 03:13 PM
for this instance of how to do this A co-worker tried and got it to work by changing the SendMessage Line to
setTimeout(function GetStepData () {gameInstance.SendMessage("Messenger", "GetStepData", UnityStepData);}, 3000);