private void OnEnable() { cameraTransition = GameObject.FindObjectOfType <CameraTransition>(); if (cameraTransition == null) { Debug.LogError(@"No CameraTransition object found."); this.enabled = false; } if (assistants.Length == 0) { Debug.LogError(@"No CameraTransitionsAssistant found."); this.enabled = false; } }
/// <summary> /// OnInspectorGUI. /// </summary> public override void OnInspectorGUI() { if (baseTarget == null) { baseTarget = this.target as CameraTransition; } EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 0.0f; EditorGUI.indentLevel = 0; EditorGUIUtility.labelWidth = 125.0f; EditorGUILayout.BeginVertical(); { EditorGUILayout.Separator(); foldoutAdvancedSettings = EditorGUILayout.Foldout(foldoutAdvancedSettings, @"Advanced settings"); if (foldoutAdvancedSettings == true) { EditorGUILayout.BeginVertical(@"Box"); { EditorGUILayout.LabelField(@"Behavior"); EditorGUI.indentLevel++; baseTarget.ProgressMode = (CameraTransition.ProgressModes)EditorGUILayout.EnumPopup(new GUIContent(@"Progress", @"How the effect progresses."), baseTarget.ProgressMode); if (baseTarget.ProgressMode == CameraTransition.ProgressModes.Manual) { EditorGUI.indentLevel++; GUI.enabled = baseTarget.IsRunning; baseTarget.Progress = EditorGUILayout.Slider(baseTarget.Progress, 0.0f, 1.0f); GUI.enabled = true; EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(@"Box"); { EditorGUILayout.LabelField(@"RenderTexture"); EditorGUI.indentLevel++; baseTarget.RenderTextureMode = (CameraTransition.RenderTextureModes)EditorGUILayout.EnumPopup(new GUIContent(@"Mode", "How handle the RenderTexture."), baseTarget.RenderTextureMode); if (baseTarget.RenderTextureMode != CameraTransition.RenderTextureModes.Automatic) { warnings += @"In manual mode, the target camera must handle its own RenderTexture."; GUI.enabled = false; } baseTarget.RenderTextureUpdateMode = (CameraTransition.RenderTextureUpdateModes)EditorGUILayout.EnumPopup(new GUIContent(@"Update", "The destination camera is updated during\nthe entire transition or only the first frame."), baseTarget.RenderTextureUpdateMode); baseTarget.RenderTextureSize = (CameraTransition.RenderTextureSizes)EditorGUILayout.EnumPopup(new GUIContent(@"Size", "The size of the render texture.\nThe smaller, the worse the quality."), baseTarget.RenderTextureSize); baseTarget.InvertRenderTexture = EditorGUILayout.Toggle(@"Invert", baseTarget.InvertRenderTexture); GUI.enabled = true; EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); } if (string.IsNullOrEmpty(warnings) == false) { EditorGUILayout.Separator(); EditorGUILayout.HelpBox(warnings, MessageType.Warning); } if (string.IsNullOrEmpty(errors) == false) { EditorGUILayout.Separator(); EditorGUILayout.HelpBox(errors, MessageType.Error); } EditorGUILayout.HelpBox(@"CameraTransition is a collection of transition effects between two cameras.", MessageType.Info); EditorGUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("[doc]", "Online documentation"), GUI.skin.label) == true) { Application.OpenURL(CameraTransitionEditorHelper.DocumentationURL); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); warnings = errors = string.Empty; if (GUI.changed == true) { EditorUtility.SetDirty(target); } EditorGUIUtility.labelWidth = EditorGUIUtility.fieldWidth = 0.0f; EditorGUI.indentLevel = 0; }
private void OnEnable() { cameras.AddRange(GameObject.FindObjectsOfType <Camera>()); if (cameras.Count > 1) { cameraTransition = GameObject.FindObjectOfType <CameraTransition>(); if (cameraTransition != null) { cameraTransition.Time = transitionTime; // Randomly select a camera. cameras.Sort(delegate(Camera a, Camera b) { return(string.Compare(a.gameObject.name, b.gameObject.name)); }); cameraIdx = random.Next(0, cameras.Count - 1); for (int i = 0; i < (cameras.Count - 0); ++i) { cameras[i].gameObject.SetActive(i == cameraIdx); } // Test all effects. Array untestedTransitions = Enum.GetValues(typeof(CameraTransitionEffects)); for (int i = 0; i < untestedTransitions.Length; ++i) { CameraTransitionEffects testedEffect = (CameraTransitionEffects)untestedTransitions.GetValue(i); if (cameraTransition.CheckTransition(testedEffect) == true #if UNITY_WEBGL // Not supported in WebGL yet. && testedEffect != CameraTransitionEffects.LinearBlur && testedEffect != CameraTransitionEffects.CrossZoom #endif ) { transitionEnum.Add(testedEffect); } else { Debug.LogWarningFormat("Transition '{0}' is not supported.", testedEffect.ToString()); } } for (int i = 0; i < transitionEnum.Count; ++i) { transitionToggles.Add(false); } } else { Debug.LogWarning(@"CameraTransition not found."); } } else { Debug.LogWarning(@"Few cameras found (at least two)."); } this.enabled = (cameras.Count > 1 && cameraTransition != null); #if ENABLE_DEMO guiShow = false; changeCameraTime = 0.5f; randomTransition = false; cameraTransition.Time = 2.0f; #endif }