/// <summary> /// Takes an impulse and plays it with the ImpulseDemo's parameters. /// This takes an impulse so you don't need to instantiate one every time. /// If you're doing the same impulse regularly, it saves traversal/breadth first searching /// </summary> /// <param name="imp">A constructed impulse of the emanation or traversal</param> private void ConfigureAndPlayImpulse(ImpulseGenerator.Impulse imp) { if (CurrentMode == ImpulseType.Emanating) { StartCoroutine(ColorSuitForEmanation()); } else { StartCoroutine(ColorSuitForTraversal()); } //To support CodeSequence Samples if (SelectedCodeSequence < 0) { //These are broken up by lines for readability imp.WithDuration(ImpulseDuration); imp.WithAttenuation(Attenuation); imp.WithEffect(effectOptions[currentEffect], EffectDuration, EffectStrength); imp.Play(); //You can do something like: //i.WithAttenuation(Attenuation).WithDuration(ImpulseDuration).WithEffect(effectOptions[CurrentEffect], EffectDuration, EffectStrength).Play(); //Chaining and Functional Programming! } else { //These are broken up by lines for readability imp.WithDuration(ImpulseDuration); imp.WithAttenuation(Attenuation); imp.WithEffect(GetCodeSequence()); imp.Play(); } }
/// <summary> /// Takes an impulse and plays it with the ImpulseDemo's parameters. /// This takes an impulse so you don't need to instantiate one every time. /// If you're doing the same impulse regularly, it saves traversal/breadth first searching /// </summary> /// <param name="imp">A constructed impulse of the emanation or traversal</param> private void ConfigureAndPlayImpulse(ImpulseGenerator.Impulse imp) { if (CurrentMode == ImpulseType.Emanating) { StartCoroutine(ColorSuitForEmanation()); } else { StartCoroutine(ColorSuitForTraversal()); } //To support HapticSequence Samples if (UseEffectSelectorSlider) { //Prevent array index out of bounds errors. Effect whichEffect = effectOptions[Mathf.Clamp(currentEffect, 0, effectOptions.Length - 1)]; //These are broken up by lines for readability imp.WithDuration(ImpulseDuration); imp.WithAttenuation(Attenuation); imp.WithEffect(whichEffect, EffectDuration, EffectStrength); imp.Play(); //You can do something like: //i.WithAttenuation(Attenuation).WithDuration(ImpulseDuration).WithEffect(effectOptions[CurrentEffect], EffectDuration, EffectStrength).Play(); //Chaining and Functional Programming! } else { //These are broken up by lines for readability imp.WithDuration(ImpulseDuration); imp.WithAttenuation(Attenuation); imp.WithEffect(GetHapticSequence()); imp.Play(); } }