K.Wagrez Posted June 20, 2025 Posted June 20, 2025 Hello everyone, A new Unigine Script question, this time I wonder if I stumbled upon a bug. I was monitoring performance of World Expression use by microprofiling various expressions using the most common operations (getting a node, getting a parent, toggling a surface...) and I stumbled upon a behavior I didn't not anticipate. My nearly empty project contains 1000 sphere node references. The source node has World Expression children, with only one active at a time (the one I'm profiling). The last one I added is a toggling surface loop: { Node parent = getNode().getParent(); // Get the signal parent object ObjectMeshStatic obj = class_cast("ObjectMeshStatic", parent); int surf = obj.findSurface("sphere"); float current_time = frac(engine.game.getTime()); if(current_time > 0.5f) { obj.setEnabled(1, surf); } else { obj.setEnabled(0, surf); } } The expression works when active, it's fine. However, when I tried to use one of my other World Expressions by Running the application, I will always find my surface turned off at the beginning. Almost as if this inactive World Expression was executed once at start. If I reopen the editor, I found myself with the same problem: the surfaces are turned off. So my question is: are World Expressions executed once at startup, even if they are set to inactive in the tree ?
bmyagkov Posted June 20, 2025 Posted June 20, 2025 Hello! 25 minutes ago, K.Wagrez said: So my question is: are World Expressions executed once at startup, even if they are set to inactive in the tree ? This is definitely not intentional behavior — we’ve filed it as a bug in our internal tracker and it will be addressed in a future update :) For now, you can resolve it by adding the following code at the beginning of your World Expression: Node node = getNode(); if (!node.isEnabled()) return; Hope this helps and thanks for reporting it! Thanks! 1
Recommended Posts