Jump to content

Get relative path to current UnigineScript file


photo

Recommended Posts

Hi,

let's say we have a test.ui file which is loaded by script.usc both located in the same folder.

script.usc:

UserInterface ui = new UserInterface(engine.getGui(), "test.ui");

Apparently, the engine is not looking the "current" directory, but in "C:/Users/user/Unigine_sdk.../bin" where the editor is located.

Is it possible to load the .ui file with a path relative to the script itself?

Thanks in advance.

Edited by karim.salama
Link to comment
  • 2 months later...
On 11/18/2021 at 4:00 PM, karim.salama said:

I ended up replacing every path with a guid and it worked.

I've the same problem trying to load my UI from relative path.
Thanks to your post I'm now able to use the asset withing the project folder just replacing with "guid://xxxxxxxxx" but I don't think it's the ideal version.
I also try to have the .ui file alongside the source folder like it was on the demo, but it's not working also in that way.

EDIT:

Thanks to karpych11 in this topic, I just found that I have to omit the data folder to load file by relative path.
Works fine for me using the following code, with file in data\gui\ from Editor SDK:
 

auto ui = UserInterface::create(gui, "gui/user_interface.ui");

 

Edited by andrea.padovani
UPDATE
Link to comment
×
×
  • Create New...