public void PushInterfaceColors(IEnumerable <ColorKey> interfaceColors) { if (interfaceColors == null) { return; } Type type = typeof(Colors); foreach (ColorKey key in interfaceColors) { FieldInfo field = type.GetField(key.Name); if (field != null && field.FieldType == typeof(Color)) { field.SetValue(this, key.color); } else { Debug.Log("Couldn't set field " + key.Name + ", was null or not type of color"); } } //get all label and button setup components //set them all to the new colors UILabel[] labels = GameObject.FindObjectsOfType <UILabel>(); UITiledSprite[] bgSprites = GameObject.FindObjectsOfType <UITiledSprite>(); UISlicedSprite[] borderSprites = GameObject.FindObjectsOfType <UISlicedSprite>(); GUI.GUIButtonSetup[] buttonSetup = GameObject.FindObjectsOfType <GUI.GUIButtonSetup>(); GUI.GUISliderSetColors[] sliderColors = GameObject.FindObjectsOfType <GUI.GUISliderSetColors>(); GUI.GUIPopupSetup[] popupSetup = GameObject.FindObjectsOfType <GUI.GUIPopupSetup>(); for (int i = 0; i < labels.Length; i++) { if (labels[i].useDefaultLabelColor) { labels[i].color = Colors.Alpha(MenuButtonTextColorDefault, labels[i].alpha); } } for (int i = 0; i < bgSprites.Length; i++) { if (bgSprites[i].useDefaultBackgroundColor) { bgSprites[i].color = Colors.Alpha(TiledBackgroundColorDefault, bgSprites[i].alpha); } } for (int i = 0; i < borderSprites.Length; i++) { if (borderSprites[i].useDefaultBorderSpriteColor) { borderSprites[i].color = Colors.Alpha(WindowBorderColorDefault, borderSprites[i].alpha); } } for (int i = 0; i < buttonSetup.Length; i++) { buttonSetup[i].RefreshColors(); } for (int i = 0; i < sliderColors.Length; i++) { sliderColors[i].RefreshColors(); } for (int i = 0; i < popupSetup.Length; i++) { popupSetup[i].RefreshColors(); } }
public IEnumerator UpdateCutscene() { mUpdatingCutscene = true; while (StartSuspended) { yield return(null); } Manager.CutsceneStart(); if (FadeIn | VRMode) { //we have to fade in for vr mode or we'll get sick Frontiers.GUI.CameraFade.StartAlphaFade(FadeOutColor, true, FadeInDuration); } bool fadeTitleCard = !string.IsNullOrEmpty(TitleCard); if (fadeTitleCard) { StartCoroutine(DisplayTitleCard(TitleCard, FadeInDuration, 1.0f, FadeOutDuration)); } if (!string.IsNullOrEmpty(CameraAnimationStarting)) { CameraSeat.GetComponent <Animation>().Play(CameraAnimationStarting, AnimationPlayMode.Stop); } if (!string.IsNullOrEmpty(LookTargetAnimationStarting)) { CameraLookTarget.GetComponent <Animation>().Play(LookTargetAnimationStarting, AnimationPlayMode.Stop); } //get the camera animatinon started before hijacking Player.Local.HijackControl(); RefreshCamera(); Player.Local.SnapToHijackedPosition(); yield return(null); State = CutsceneState.Starting; Interfaces.BroadcastMessage("OnCutsceneStart", SendMessageOptions.DontRequireReceiver); Props.BroadcastMessage("OnCutsceneStart", SendMessageOptions.DontRequireReceiver); double startTime = WorldClock.RealTime; float startDuration = 0.01f; //if we're in vr mode and we have a specified hold period, use that for timing if (VRMode) { //this will end up waiting for zero seconds if there's no intro stuff set, which is fine if (HoldStaticCameraStart >= 0) { startTime += HoldStaticCameraStart; } else if (!string.IsNullOrEmpty(CameraAnimationStarting)) { startTime += CameraSeat.GetComponent <Animation>()[CameraAnimationStarting].length; } } else { //otherwise just use the camera animation if (!string.IsNullOrEmpty(CameraAnimationStarting)) { startTime += CameraSeat.GetComponent <Animation>()[CameraAnimationStarting].length; } } while (WorldClock.RealTime < (startTime + startDuration)) { yield return(null); } State = CutsceneState.Idling; if (VRMode && StaticCameraSeatStart != StaticCameraSeatIdle) { //we have to fade out/in before switching to a new static camera mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } } RefreshCamera(); Interfaces.BroadcastMessage("OnCutsceneIdleStart", SendMessageOptions.DontRequireReceiver); Props.BroadcastMessage("OnCutsceneIdleStart", SendMessageOptions.DontRequireReceiver); if (!FinishAutomatically) { while (State == CutsceneState.Idling) { yield return(null); } } Interfaces.BroadcastMessage("OnCutsceneIdleEnd", SendMessageOptions.DontRequireReceiver); Props.BroadcastMessage("OnCutsceneIdleEnd", SendMessageOptions.DontRequireReceiver); State = CutsceneState.Finishing; if (VRMode && StaticCameraSeatIdle != StaticCameraSeatEnd) { //we have to fade out/in before switching to a new static camera mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } } RefreshCamera(); //if we're in vr mode and we have a specified hold period, use that for timing double endStartTime = WorldClock.RealTime; float endDuration = 0.01f; if (VRMode) { if (HoldStaticCameraStart >= 0) { endDuration = HoldStaticCameraEnd; } else if (!string.IsNullOrEmpty(CameraAnimationFinishing)) { endDuration = CameraSeat.GetComponent <Animation>()[CameraAnimationFinishing].length; } //in vr mode we need at least 1 second to fade out endDuration = Mathf.Max(1f, endDuration); } else { //otherwise just use the camera animation if (!string.IsNullOrEmpty(CameraAnimationFinishing)) { endDuration = CameraSeat.GetComponent <Animation>()[CameraAnimationFinishing].length; } } //see if we need to start fading out before the animation is done double fadeOutStartTime = -1f; bool shouldFade = false; if (FadeOut | VRMode) { //we HAVE to fade out for vr mode or we'll get sick shouldFade = true; FadeOutDuration = Mathf.Min(FadeOutDuration, endDuration); fadeOutStartTime = endStartTime + endDuration - FadeOutDuration; } while (WorldClock.RealTime < (endStartTime + endDuration)) { //see if we're supposed to start fading if (shouldFade && WorldClock.RealTime > fadeOutStartTime) { Debug.Log("Starting fade out"); shouldFade = false; Frontiers.GUI.CameraFade.StartAlphaFade(FadeOutColor, false, FadeOutDuration); } yield return(null); } if (!VRMode && !string.IsNullOrEmpty(CameraAnimationFinishing)) { while (CameraSeat.GetComponent <Animation>()[CameraAnimationFinishing].normalizedTime < 1f) { yield return(null); } } State = CutsceneState.Finished; OnFinished(); yield break; }