// ------------------------------------------------ public void SoundMarkerSelected(SoundMarker selectedSound) { // Change the InputField text soundNameInputField.text = selectedSound.hotspot.name; soundLabelResizeText.text = selectedSound.hotspot.name; // Change the 2D UI representation soundIconImage.sprite = selectedSound.iconSprite; // Set the trigger and loop toggles triggerPlaybackToggle.isOn = selectedSound.hotspot.triggerPlayback; loopAudioToggle.isOn = selectedSound.hotspot.loopAudio; loopAudioToggle.interactable = (triggerPlaybackToggle.isOn == true); SetTriggerVisualInteractiveState(loopAudioToggle); pitchSlider.value = selectedSound.hotspot.pitchBend; volumeSlider.value = selectedSound.hotspot.soundVolume; // Change the colour of the UI Color newCol = selectedSound.color; repositionImage.color = newCol; soundIconImage.color = newCol; soundColorImage.color = newCol; minRadiusSlider.SetColorTint(newCol); maxRadiusSlider.SetColorTint(newCol); minRadiusSlider.SetSliderRadius(selectedSound.soundMinDist, notifyDelegate: false); maxRadiusSlider.SetSliderRadius(selectedSound.soundMaxDist, notifyDelegate: false); UnityEngine.UI.ColorBlock cols = soundSrcButton.colors; cols.normalColor = newCol; cols.highlightedColor = newCol.ColorWithBrightness(-0.15f); cols.pressedColor = newCol.ColorWithBrightness(-0.3f); soundSrcButton.colors = cols; if (selectedSound.hotspot.soundFile.isDefaultSoundFile) { soundFilenameText.text = "Tap to change sound"; } else { soundFilenameText.text = "\"" + selectedSound.hotspot.soundFile.filenameWithExtension + "\""; } int charLimit = 21; int charsOver = soundFilenameText.text.Length - charLimit; float percentOverCharLimit = (charsOver > 0) ? (charsOver / 8f) : 0; soundFilenameText.fontSize = 36 - (int)(8 * percentOverCharLimit); }
private void updateUIColor(Color newCol, bool notifyDelegate = true) { repositionImage.color = newCol; soundShapeImage.color = newCol; soundAppearanceImage.color = newCol; minRadiusSlider.SetColorTint(newCol); maxRadiusSlider.SetColorTint(newCol); UnityEngine.UI.ColorBlock cols = soundSrcButton.colors; cols.normalColor = newCol; cols.highlightedColor = newCol.ColorWithBrightness(-0.15f); cols.pressedColor = newCol.ColorWithBrightness(-0.3f); soundSrcButton.colors = cols; if (!notifyDelegate) { return; } canvasDelegate.objectSelection.SetSelectionRadiusColor(newCol); }
// ------------------------------------------------ public void SoundMarkerSelected(SoundMarker selectedSound) { // Change the InputField text soundNameInputField.text = selectedSound.hotspot.name; soundLabelResizeText.text = selectedSound.hotspot.name; // Change the 2D UI representation soundIconImage.sprite = selectedSound.iconSprite; // Set the trigger and loop toggles triggerPlaybackToggle.isOn = selectedSound.hotspot.triggerPlayback; loopAudioToggle.isOn = selectedSound.hotspot.loopAudio; loopAudioToggle.interactable = (triggerPlaybackToggle.isOn == true); SetTriggerVisualInteractiveState(loopAudioToggle); pitchSlider.value = selectedSound.hotspot.pitchBend; volumeSlider.value = selectedSound.hotspot.soundVolume; // Filter values freqCutoffSlider.value = selectedSound.hotspot.freqCutoff; phaserSlider.value = selectedSound.hotspot.phaserLevel; distortionSlider.value = selectedSound.hotspot.distortion; // Syncronisation button subtitle syncSubtitleText.text = "Edit synchronised Sound Markers"; if (canvasDelegate != null) { System.Collections.Generic.HashSet <string> syncedMarkers = canvasDelegate.SynchronisedMarkerIDsWithMarkerID(selectedSound.hotspot.id); if (syncedMarkers != null && syncedMarkers.Count > 1) { syncSubtitleText.text = string.Format("Synced with {0} Sound Marker{1}", syncedMarkers.Count - 1, (syncedMarkers.Count == 2 ? "" : "s")); } } // Change the colour of the UI Color newCol = selectedSound.color; repositionImage.color = newCol; soundIconImage.color = newCol; soundColorImage.color = newCol; minRadiusSlider.SetColorTint(newCol); maxRadiusSlider.SetColorTint(newCol); minRadiusSlider.SetSliderRadius(selectedSound.soundMinDist, notifyDelegate: false); maxRadiusSlider.SetSliderRadius(selectedSound.soundMaxDist, notifyDelegate: false); UnityEngine.UI.ColorBlock cols = soundSrcButton.colors; cols.normalColor = newCol; cols.highlightedColor = newCol.ColorWithBrightness(-0.15f); cols.pressedColor = newCol.ColorWithBrightness(-0.3f); soundSrcButton.colors = cols; if (selectedSound.hotspot.soundFile.isDefaultSoundFile) { soundFilenameText.text = "Tap to change sound"; } else { soundFilenameText.text = "\"" + selectedSound.hotspot.soundFile.filenameWithExtension + "\""; } int charLimit = 21; int charsOver = soundFilenameText.text.Length - charLimit; float percentOverCharLimit = (charsOver > 0) ? (charsOver / 8f) : 0; soundFilenameText.fontSize = 36 - (int)(8 * percentOverCharLimit); }