コード例 #1
0
        protected override void Init(FObject obj)
        {
            base.Init(obj);

            _animEvt = (FPlayAnimationEvent)_evt;

            _animTrack = (FAnimationTrack)_animEvt.GetTrack();
        }
コード例 #2
0
        public static void SetAnimationClip(FPlayAnimationEvent animEvent, AnimationClip animClip)
        {
            FAnimationEventInspector editor = (FAnimationEventInspector)CreateEditor(animEvent, typeof(FAnimationEventInspector));

            editor.SetAnimationClip(animClip);

            DestroyImmediate(editor);
            FAnimationTrackInspector.RebuildStateMachine((FAnimationTrack)animEvent.GetTrack());
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            serializedObject.Update();

            if (_animationClip.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("There's no Animation Clip", MessageType.Warning);
                Rect helpBoxRect = GUILayoutUtility.GetLastRect();

                float yCenter = helpBoxRect.center.y;

                helpBoxRect.xMax  -= 3;
                helpBoxRect.xMin   = helpBoxRect.xMax - 50;
                helpBoxRect.yMin   = yCenter - 12.5f;
                helpBoxRect.height = 25f;

                if (GUI.Button(helpBoxRect, "Create"))
                {
                    CreateAnimationClip(_animEvent);
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(_animationClip);

            Rect animationClipRect = GUILayoutUtility.GetLastRect();

            if (Event.current.type == EventType.DragUpdated && animationClipRect.Contains(Event.current.mousePosition))
            {
                int numAnimations = NumAnimationsDragAndDrop(_animEvent.Sequence.FrameRate);
                if (numAnimations > 0)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                }
            }
            else if (Event.current.type == EventType.DragPerform && animationClipRect.Contains(Event.current.mousePosition))
            {
                if (NumAnimationsDragAndDrop(_animEvent.Sequence.FrameRate) > 0)
                {
                    DragAndDrop.AcceptDrag();
                    AnimationClip clip = GetAnimationClipDragAndDrop(_animEvent.Sequence.FrameRate);
                    if (clip != null)
                    {
                        _animationClip.objectReferenceValue = clip;
                    }
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                AnimationClip clip = (AnimationClip)_animationClip.objectReferenceValue;
                if (clip)
                {
                    if (clip.frameRate != _animEvent.GetTrack().GetTimeline().Sequence.FrameRate)
                    {
                        Debug.LogError(string.Format("Can't add animation, it has a different frame rate from the sequence ({0} vs {1})",
                                                     clip.frameRate, _animEvent.GetTrack().GetTimeline().Sequence.FrameRate));

                        _animationClip.objectReferenceValue = null;
                    }
                    else
                    {
                        SerializedProperty frameRangeEnd = _frameRange.FindPropertyRelative("_end");
                        FrameRange         maxFrameRange = _animEvent.GetMaxFrameRange();
                        frameRangeEnd.intValue = Mathf.Min(_animEvent.FrameRange.Start + Mathf.RoundToInt(clip.length * clip.frameRate), maxFrameRange.End);
                    }
                }
            }

            if (!_animEvent.IsAnimationEditable())
            {
                EditorGUILayout.IntSlider(_startOffset, 0, _animEvent.GetMaxStartOffset());
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #4
0
 private void RebuildAnimationTrack()
 {
     FAnimationTrackInspector.RebuildStateMachine((FAnimationTrack)_animEvt.GetTrack());
 }