Jump to content

[SOLVED] Create world variable at runtime


photo

Recommended Posts

Hi unclebob, waiting for the summer holidays and so no bother you for a few days ;)

 

I'm implemeting a widget animation system, so I've defined animators in charge of this operation as user class instances. Because of Widget doesn't have get/setVariable and properties, for each animated widget, I've created in the world a NodeDummy ("widget avatar") whose variable references the animator in charge of modify the widget and a property with the parameters needed to set up the animator. Furthermore I can configure widget animations using UnigineEditor in a more friendly way using the property editor.

When I add nodes dynamically, my loader identifies one of these "widget avatars" so it generates the widgets animators but it also needs to get the reference to the widget that must be animated. I solved this using global variables because it's very similar to the export="1" functionallity used when .ui files are loaded, and it's compatible with loaded user interfaces.

This works ok for all the variables that can be retreived with the methods mentioned above, but, what happens if I have more than one instance of a widget that needs to be animated? I have the option to create an application registry (string:Widget) where I can subscribe the animated widgets, and the loader can retrieve these widgets using this registry, but my question is if it's possible avoid this and to be able to declare global variables at runtime.

 

I was interested if UnigineScript has this functionallity, not only for this purpose, but in general.

 

PD: A suggestion, when you delete a node in Unigine::Editor and it has a user-class variable assigned the application crashes, I've implemented a editor plugin with a button to delete the node checking its variable and deleting it before node destruction, but I think could be interesting to include this functionallity in Unigine::Editor or receive events before and after a node is added or removed from editor/world.

Link to comment

Hey In,

 

Thanks for detailed description!

 

There's no such functionatily in the script though. I would say that it's better to use map here (string -> Widget). If you really want to "add global variable" then I think you're able to do a hacky way. Instead of creating variables you can create Expression instance with proper variable within.

Link to comment
×
×
  • Create New...