public AnimationClip GetClosingAnimation() { if (Panel == null) { return(null); } var animator = Panel.GetComponent <Animator>(); if (animator == null) { return(null); } var animatorController = animator.runtimeAnimatorController; if (animatorController == null) { return(null); } var animation = animatorController.animationClips.FirstOrDefault(clip => clip.name == "PanelClosed"); if (animation == null || ForceMirrored) { animation = animatorController.animationClips.FirstOrDefault(clip => clip.name == "PanelOpened"); } return(animation); }
private void SamplePanelAnimator(WooPanel panel) { if (panel == null || panel.GetComponent <Animator>() == null) { return; } AnimationClip animation = null; var animatorController = panel.GetComponent <Animator>().runtimeAnimatorController; animation = panelNodes[panel].GetActiveAnimation(); var time = panelNodes[panel].simulatedTime; time = Mathf.Clamp(time, 0.0f, 1.0f); if (panelNodes[panel].IsClosed || panelNodes[panel].IsClosing || panelNodes[panel].IsWaitingToClose) { if (panelNodes[panel].IsMirrored()) { time = 1.0f - time; } } if (animation != null) { #if UNITY_EDITOR if (AnimationMode.InAnimationMode()) { if (!Application.isPlaying) { AnimationMode.SampleAnimationClip(panel.gameObject, animation, animation.length * time); } } else { if (!Application.isPlaying && panel.GetLayerIndex() != -1) { panel.GetAnimator().Play(animation.name, panel.GetLayerIndex(), time); panel.GetAnimator().Update(Time.deltaTime); panel.GetAnimator().StopPlayback(); } } #endif if (Application.isPlaying && panel.GetLayerIndex() != -1) { panel.GetAnimator().Play(animation.name, panel.GetLayerIndex(), time); panel.GetAnimator().Update(Time.deltaTime); panel.GetAnimator().StopPlayback(); } } }
private void DrawAnimatorProperty(WooPanel panel) { GUILayout.BeginVertical(); GUILayout.Space(10.0f); panel.GetComponent <Animator>().runtimeAnimatorController = EditorGUILayout.ObjectField(panel.GetComponent <Animator>().runtimeAnimatorController, typeof(UnityEditor.Animations.AnimatorController), false) as UnityEditor.Animations.AnimatorController; GUILayout.EndVertical(); }
private void DrawScriptProperty(WooPanel panel) { GUILayout.BeginVertical(); GUILayout.Space(10.0f); var serializedObject = new SerializedObject(panel.GetComponent <WooPanel>()); var it = serializedObject.GetIterator(); it.NextVisible(true); EditorGUILayout.PropertyField(it, GUIContent.none, true); GUILayout.EndVertical(); }