protected void DrawTransitionProperties() { EditorGUILayout.LabelField("Transition Properties", EditorStyles.boldLabel); EditorGUI.indentLevel = (EditorGUI.indentLevel + 1); EditorGUILayout.PropertyField(this.m_Transition, new GUIContent("Transition")); // Get the transition UIScene.Transition transition = (UIScene.Transition) this.m_Transition.enumValueIndex; if (transition != UIScene.Transition.None && transition != UIScene.Transition.Animation) { EditorGUI.indentLevel = (EditorGUI.indentLevel + 1); EditorGUILayout.PropertyField(this.m_TransitionDuration, new GUIContent("Duration")); EditorGUILayout.PropertyField(this.m_TransitionEasing, new GUIContent("Easing")); EditorGUI.indentLevel = (EditorGUI.indentLevel - 1); } else if (transition == UIScene.Transition.Animation) { EditorGUILayout.PropertyField(this.m_AnimateInTrigger, new GUIContent("Animate In Trigger")); EditorGUILayout.PropertyField(this.m_AnimateOutTrigger, new GUIContent("Animate Out Trigger")); UIScene scene = (target as UIScene); Animator animator = scene.animator; if (animator == null || animator.runtimeAnimatorController == null) { Rect controlRect = EditorGUILayout.GetControlRect(); controlRect.xMin = (controlRect.xMin + EditorGUIUtility.labelWidth); if (GUI.Button(controlRect, "Auto Generate Animation", EditorStyles.miniButton)) { System.Collections.Generic.List <string> triggersList = new System.Collections.Generic.List <string>(); triggersList.Add(this.m_AnimateInTrigger.stringValue); triggersList.Add(this.m_AnimateOutTrigger.stringValue); // Generate the animator controller UnityEditor.Animations.AnimatorController animatorController = UIAnimatorControllerGenerator.GenerateAnimatorContoller(triggersList, scene.gameObject.name); if (animatorController != null) { if (animator == null) { animator = scene.gameObject.AddComponent <Animator>(); } UnityEditor.Animations.AnimatorController.SetAnimatorController(animator, animatorController); } } } } EditorGUI.indentLevel = (EditorGUI.indentLevel - 1); }
/// <summary> /// Transitions out of the active scene and in to the new one. /// </summary> /// <param name="scene"></param> public void TransitionToScene(UIScene scene) { UIScene.Transition transition = scene.transition; float transitionDuration = scene.transitionDuration; Tweens.TweenEasing transitionEasing = scene.transitionEasing; // Transition out of the current scenes UIScene[] activeScenes = this.GetActiveScenes(); foreach (UIScene activeScene in activeScenes) { // Transition the scene out activeScene.TransitionOut(transition, transitionDuration, transitionEasing); } // Transition in the new scene scene.TransitionIn(transition, transitionDuration, transitionEasing); }