// updating // // at each update: // private void Update() { // for being enabled: adjusting volume and time, aesthetics cycling, vision coloring // if (motivating && dependencies.areMet()) { float maxVolumeToUse = (audioIncreasingEnabled ? volumeMax : volumeMin); if (maxVolumeToUse >= 0f) { if (audioRestartsUponNonzeroing && (audioSource.volume == 0f)) { setAudioTimeTo(0f); } audioSource.volume = Mathf.Max(volumeMin, audioSource.volume.honed(maxVolumeToUse, volumeIncrement)); if (aestheticsCycling) { if ((Time.time - timeOfLastAestheticsCycling) > aestheticsCyclingInterval) { BoosterAestheticsSetCycler.advanceCycleGlobally(false); timeOfLastAestheticsCycling = Time.time; } } if (visionColoring) { Color colorToFadeTo = ((Any.itemsIn(colors)) ? (colorsGoInOrder ? colors[colorIndex] : colors[Random.Range(0, colors.Length)]) : Random.ColorHSV(0f, 1f, 1f, 1f, 0f, 1f, randomVisionColoringOpacity, randomVisionColoringOpacity)); if ((Time.time - timeOfLastFade) > fadingInterval) { SteamVR_Fade.Start(colorToFadeTo, fadingDuration); timeOfLastFade = Time.time; } if (Any.itemsIn(colors) && colorsGoInOrder) { colorIndex++; if (colorIndex >= colors.Length) { colorIndex = 0; } } } } } // for not being enabled: adjusting volume, vision coloring // else { audioSource.volume = Mathf.Min(volumeMax, audioSource.volume.honed(volumeMin, volumeIncrement)); SteamVR_Fade.Start(new Color(0f, 0f, 0f, 0f), fadingDuration); } }
// at the start: // protected override void Start() { base.Start(); // track the left and right instances of this class // if (leftInstance) { left = this; } else { right = this; } // apply the cycle // applyCycle(); }