Hi, I’m trying to delete the scene and load the main menu when I click. The problem is that nothing happens when i click.
PS: I tried to do the same thing from a button on ui and it works.
Code: https://pastebin.com/YGgDPZ9g
Thanks.
Hi, I’m trying to delete the scene and load the main menu when I click. The problem is that nothing happens when i click.
PS: I tried to do the same thing from a button on ui and it works.
Code: https://pastebin.com/YGgDPZ9g
Thanks.
Still not working
This line is not begin executed:
scene_.RemoveAllChildren();
I also tried:
File loadFile(fileSystem.programDir + “Data/Scenes/empty.xml”, FILE_READ); //clear scene
scene_.LoadXML(loadFile);
Add more print statements, make every other line a print statement indicating the next call, and with the last one being “Finished GoToMenu.” This will make sure you’re not crashing the angelscript context somewhere.
If your original “Creating Menu (:” message prints in both cases then something is happening somewhere, and you need to narrow it down.
I added a lot of prints and I realized that when I call the GoToMenu() function from DelayedExecute the variable scene_ is null, but when I call it from the ui button no.
if(scene_!=null){
Print(“scene != null”);
scene_.RemoveAllChildren();
}else Print(“null scene”);
Output from DelayedExecute: “null scene”.
Output from ui button: “scene != null”.
EDIT: I did some tests and it seems that the script loaded by UrhoPlayer is in another angelscript context that the script that calls the function GoToMenu()
Test i made: https://pastebin.com/4ZTDCT11
Fixed in the worst possible way i think. (:
I added this line to HandleUpdate:
if(scene_.GetChild(“tomenu”)!=null)GoToMenu();
Then when i have to call GoToMenu(); i just do:
scene.CreateChild(“tomenu”);
Couldn’t you store that in a bool
ean?
No, it seems that when I use #include from a scriptinstance it creates a new context or something like that.
This doesn’t sound right. The context shouldn’t be the problem, script-module might be, but I still wouldn’t expect that here.
Is your project small enough to post? If not I have a reasonably small delta for adding asPEEK debugging that might work (you can use the web-based debugger, or I have a full IDE for Angelscript). It was never and probably never will be merged due to instability (it’ll time out randomly and can sometimes jam things up while running … it’s better than nothing though).
My project has more than 40 script files. I’m going to write a minimal example (only 2 script files).
Tomorrow I upload the files.
Scripts:
https://pastebin.com/ULcVdfga (Global.as)
https://pastebin.com/ejLLAK2K (Instance.as)
Scene:
https://pastebin.com/Nm4utjWe (scene.xml)
cmd:
Urho3DPlayer.exe Scripts/Global.as