PlaySoundRawNode: add loop option
This commit is contained in:
parent
4fa9d8b980
commit
55ce26c02f
|
@ -2,15 +2,14 @@ package armory.logicnode;
|
|||
|
||||
class PlaySoundRawNode extends LogicNode {
|
||||
|
||||
/** The name of the sound */
|
||||
public var property0: String;
|
||||
/**
|
||||
* Override sample rate
|
||||
*/
|
||||
/** Whether to loop the playback */
|
||||
public var property1: Bool;
|
||||
/**
|
||||
* Playback sample rate
|
||||
*/
|
||||
public var property2: Int;
|
||||
/** Override sample rate */
|
||||
public var property2: Bool;
|
||||
/** Playback sample rate */
|
||||
public var property3: Int;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
|
@ -18,8 +17,8 @@ class PlaySoundRawNode extends LogicNode {
|
|||
|
||||
override function run(from: Int) {
|
||||
iron.data.Data.getSound(property0, function(sound: kha.Sound) {
|
||||
if (property1) sound.sampleRate = property2;
|
||||
iron.system.Audio.play(sound, false);
|
||||
if (property2) sound.sampleRate = property3;
|
||||
iron.system.Audio.play(sound, property1);
|
||||
});
|
||||
runOutput(0);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,14 @@ class PlaySoundNode(Node, ArmLogicTreeNode):
|
|||
|
||||
property0: PointerProperty(name='', type=bpy.types.Sound)
|
||||
property1: BoolProperty(
|
||||
name='Loop',
|
||||
description='Play the sound in a loop',
|
||||
default=False)
|
||||
property2: BoolProperty(
|
||||
name='Use Custom Sample Rate',
|
||||
description='If enabled, override the default sample rate',
|
||||
default=False)
|
||||
property2: IntProperty(
|
||||
property3: IntProperty(
|
||||
name='Sample Rate',
|
||||
description='Set the sample rate used to play this sound',
|
||||
default=44100,
|
||||
|
@ -27,13 +31,15 @@ class PlaySoundNode(Node, ArmLogicTreeNode):
|
|||
def draw_buttons(self, context, layout):
|
||||
layout.prop_search(self, 'property0', bpy.data, 'sounds', icon='NONE', text='')
|
||||
|
||||
layout.prop(self, 'property1')
|
||||
|
||||
layout.label(text="Overrides:")
|
||||
# Sample rate
|
||||
split = layout.split(factor=0.15, align=False)
|
||||
split.prop(self, 'property1', text="")
|
||||
split.prop(self, 'property2', text="")
|
||||
row = split.row()
|
||||
if not self.property1:
|
||||
if not self.property2:
|
||||
row.enabled = False
|
||||
row.prop(self, 'property2')
|
||||
row.prop(self, 'property3')
|
||||
|
||||
add_node(PlaySoundNode, category='Sound')
|
||||
|
|
Loading…
Reference in a new issue