Browse Source

Added waitDuration property to Play Usfxr Sound command

master
chrisgregan 10 years ago
parent
commit
2fc0e2ebf2
  1. 15
      Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs
  2. 34
      Assets/FungusExamples/Usfxr/UsfxrAudioExample.unity

15
Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs

@ -4,12 +4,13 @@
[CommandInfo("Audio", [CommandInfo("Audio",
"Play Usfxr Sound", "Play Usfxr Sound",
"Plays a usfxr synth sound. Use the usfxr editor [Window > Generate usfxr Sound Effects] to create the SettingsString. Set a ParentTransform if using positional sound. See https://github.com/zeh/usfxr for more information about usfxr.")] "Plays a usfxr synth sound. Use the usfxr editor [Tools > Fungus > Utilities > Generate usfxr Sound Effects] to create the SettingsString. Set a ParentTransform if using positional sound. See https://github.com/zeh/usfxr for more information about usfxr.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class PlayUsfxrSound : Command { public class PlayUsfxrSound : Command {
protected SfxrSynth _synth = new SfxrSynth(); protected SfxrSynth _synth = new SfxrSynth();
public Transform ParentTransform = null; public Transform ParentTransform = null;
public String SettingsString = ""; public String SettingsString = "";
public float waitDuration = 0;
//Call this if the settings have changed //Call this if the settings have changed
protected void UpdateCache() { protected void UpdateCache() {
@ -27,6 +28,18 @@
public override void OnEnter() { public override void OnEnter() {
_synth.SetParentTransform(ParentTransform); _synth.SetParentTransform(ParentTransform);
_synth.Play(); _synth.Play();
if (waitDuration == 0f)
{
Continue();
}
else
{
Invoke ("DoWait", waitDuration);
}
}
protected void DoWait()
{
Continue(); Continue();
} }

34
Assets/FungusExamples/Usfxr/UsfxrAudioExample.unity

@ -262,9 +262,9 @@ MonoBehaviour:
y: 10 y: 10
width: 100 width: 100
height: 40 height: 40
sequenceName: New Sequence itemId: -1
blockName: New Sequence
description: description:
runSlowInEditor: 1
eventHandler: {fileID: 0} eventHandler: {fileID: 0}
commandList: [] commandList: []
--- !u!4 &1457713103 --- !u!4 &1457713103
@ -327,7 +327,7 @@ MonoBehaviour:
scrollPos: {x: 352.51593, y: 571.148438} scrollPos: {x: 352.51593, y: 571.148438}
variablesScrollPos: {x: 0, y: 0} variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1 variablesExpanded: 1
sequenceViewHeight: 400 blockViewHeight: 400
zoom: 1 zoom: 1
scrollViewRect: scrollViewRect:
serializedVersion: 2 serializedVersion: 2
@ -335,16 +335,18 @@ MonoBehaviour:
y: -889 y: -889
width: 1187 width: 1187
height: 1416 height: 1416
selectedSequence: {fileID: 1818246749} selectedBlock: {fileID: 1818246749}
selectedCommands: [] selectedCommands:
- {fileID: 1818246745}
variables: [] variables: []
description: "This scene shows how to use Usfxr to play\nprocedural sound effects. description: "This scene shows how to use Usfxr to play\nprocedural sound effects.
\nSelect: Window > Generate usfxr Sound Effects\nto edit your own procedural sounds." \nSelect: Window > Generate usfxr Sound Effects\nto edit your own procedural sounds."
runSlowDuration: .25 pauseAfterCommand: 0
colorCommands: 1 colorCommands: 1
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
nextCommandId: 4 localizationId:
nextItemId: 5
--- !u!114 &1818246744 --- !u!114 &1818246744
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -356,7 +358,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3} m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
parentSequence: {fileID: 1818246749} parentBlock: {fileID: 1818246749}
--- !u!114 &1818246745 --- !u!114 &1818246745
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -368,11 +370,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3} m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
commandId: 3 itemId: 3
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
ParentTransform: {fileID: 0} ParentTransform: {fileID: 0}
SettingsString: 0,.5,,.0259,.3178,.2433,.3,.7694,,,,,,,,,.4286,.673,,,,,,,,1,,,,,, SettingsString: 0,.5,,.0259,.3178,.2433,.3,.7694,,,,,,,,,.4286,.673,,,,,,,,1,,,,,,
waitDuration: .25
--- !u!114 &1818246746 --- !u!114 &1818246746
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -384,11 +387,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3} m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
commandId: 2 itemId: 2
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
ParentTransform: {fileID: 0} ParentTransform: {fileID: 0}
SettingsString: 1,.5,,.1749,.0094,.2571,.3,.6665,.2,-.2852,,,,,,,,,,,.2159,.1001,,.1209,-.1511,1,,,,,, SettingsString: 1,.5,,.1749,.0094,.2571,.3,.6665,.2,-.2852,,,,,,,,,,,.2159,.1001,,.1209,-.1511,1,,,,,,
waitDuration: .25
--- !u!114 &1818246747 --- !u!114 &1818246747
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -400,11 +404,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3} m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
commandId: 1 itemId: 1
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
ParentTransform: {fileID: 0} ParentTransform: {fileID: 0}
SettingsString: 1,.5,,.142,,.1233,.3,.4328,,,,,,,,,,,,,,,,,,1,,,.1,,, SettingsString: 1,.5,,.142,,.1233,.3,.4328,,,,,,,,,,,,,,,,,,1,,,.1,,,
waitDuration: .25
--- !u!114 &1818246748 --- !u!114 &1818246748
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -416,11 +421,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3} m_Script: {fileID: 11500000, guid: a3ff412ad89846a47a70a620a222cbf8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
commandId: 0 itemId: 0
errorMessage: errorMessage:
indentLevel: 0 indentLevel: 0
ParentTransform: {fileID: 0} ParentTransform: {fileID: 0}
SettingsString: 0,.5,,.0004,.354,.414,.3,.731,,,,,,,,,,,,,,,,,,1,,,,,, SettingsString: 0,.5,,.0004,.354,.414,.3,.731,,,,,,,,,,,,,,,,,,1,,,,,,
waitDuration: .25
--- !u!114 &1818246749 --- !u!114 &1818246749
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -438,9 +444,9 @@ MonoBehaviour:
y: -489 y: -489
width: 138 width: 138
height: 40 height: 40
sequenceName: Sound Sequence itemId: 4
blockName: Sound Sequence
description: description:
runSlowInEditor: 1
eventHandler: {fileID: 1818246744} eventHandler: {fileID: 1818246744}
commandList: commandList:
- {fileID: 1818246748} - {fileID: 1818246748}

Loading…
Cancel
Save