Created
March 8, 2019 16:47
-
-
Save zicklag/d2e7713b02c43ef58e0f0c9952da29df to your computer and use it in GitHub Desktop.
UiScript exampel for Armory3D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package arm; | |
import iron.Scene; | |
import iron.App; | |
import iron.system.Time; | |
import armory.system.Event; | |
import armory.trait.internal.CanvasScript; | |
class UiScript extends iron.Trait { | |
var canvas:CanvasScript; | |
public function new() { | |
super(); | |
notifyOnInit(function() { | |
// Get canvas attached to scene | |
canvas = Scene.active.getTrait(CanvasScript); | |
// Once the canvas is ready, tell it to start running the update function | |
canvas.notifyOnReady(function() { | |
notifyOnUpdate(update); | |
}); | |
}); | |
} | |
// This runs every frame because of the `notifyOnUPdate(update)` code above | |
function update() { | |
// Canvas may be still being loaded | |
if (!canvas.ready) return; | |
// Get image | |
var img = canvas.getElement("selection"); | |
// Set image's x based on the "qb_selected" property of the object | |
// that this trait is applied to. | |
if (this.object.properties["qb_selected"] == 0) { | |
img.x = 510; | |
} else { | |
img.x = 610; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment