Add "On Application State" node
This commit is contained in:
parent
9ad68b561a
commit
b132d4b171
20
Sources/armory/logicnode/OnApplicationStateNode.hx
Normal file
20
Sources/armory/logicnode/OnApplicationStateNode.hx
Normal file
|
@ -0,0 +1,20 @@
|
|||
package armory.logicnode;
|
||||
|
||||
@:access(iron.Trait)
|
||||
class OnApplicationStateNode extends LogicNode {
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
tree.notifyOnInit(init);
|
||||
}
|
||||
|
||||
function init() {
|
||||
kha.System.notifyOnApplicationState(
|
||||
() -> runOutput(0), // On foreground
|
||||
null, // On resume
|
||||
null, // On pause
|
||||
() -> runOutput(1), // On background
|
||||
() -> runOutput(2) // On shutdown
|
||||
);
|
||||
}
|
||||
}
|
17
blender/arm/logicnode/event/LN_on_application_state.py
Normal file
17
blender/arm/logicnode/event/LN_on_application_state.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
|
||||
class OnApplicationStateNode(ArmLogicTreeNode):
|
||||
"""Listen to different application state changes."""
|
||||
bl_idname = 'LNOnApplicationStateNode'
|
||||
bl_label = 'On Application State'
|
||||
arm_version = 1
|
||||
|
||||
def init(self, context):
|
||||
super().init(context)
|
||||
self.add_output('ArmNodeSocketAction', 'On Foreground')
|
||||
self.add_output('ArmNodeSocketAction', 'On Background')
|
||||
self.add_output('ArmNodeSocketAction', 'On Shutdown')
|
||||
|
||||
|
||||
add_node(OnApplicationStateNode, category=PKG_AS_CATEGORY)
|
Loading…
Reference in a new issue