private void DoAnimationsField(SerializedProperty property)
        {
            GUILayout.Space(AnimancerGUI.StandardSpacing - 1);

            if (_Animations == null)
            {
                _Animations = new ReorderableList(property.serializedObject, property.Copy())
                {
                    drawHeaderCallback  = DrawAnimationsHeader,
                    drawElementCallback = DrawAnimationElement,
                    elementHeight       = AnimancerGUI.LineHeight,
                    onRemoveCallback    = RemoveSelectedElement,
                };
            }

            _RemoveAnimationIndex = -1;

            GUILayout.BeginVertical();
            _Animations.DoLayoutList();
            GUILayout.EndVertical();

            if (_RemoveAnimationIndex >= 0)
            {
                property.DeleteArrayElementAtIndex(_RemoveAnimationIndex);
            }

            AnimancerGUI.HandleDragAndDropAnimations(GUILayoutUtility.GetLastRect(), (clip) =>
            {
                var index                    = property.arraySize;
                property.arraySize           = index + 1;
                var element                  = property.GetArrayElementAtIndex(index);
                element.objectReferenceValue = clip;
                property.serializedObject.ApplyModifiedProperties();
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// If <see cref="AnimationClip"/>s or <see cref="IAnimationClipSource"/>s are dropped inside the `dropArea`,
 /// this method creates a new state in the `target` for each animation.
 /// </summary>
 public static void HandleDragAndDropAnimations(Rect dropArea, IAnimancerComponent target, int layerIndex)
 {
     AnimancerGUI.HandleDragAndDropAnimations(dropArea, (clip) =>
     {
         target.Playable.Layers[layerIndex].GetOrCreateState(clip);
     });
 }