예제 #1
0
        private void SetSprite(SlotAndAttachment slot, Sprite sprite)
        {
            _attachmentNames.Clear();
            _clonedSkin.FindNamesForSlot(slot.SlotIndex, _attachmentNames);

            var attachmentName = _attachmentNames.Count > 0
                ? _attachmentNames[0]
                : string.Empty;

            if (string.IsNullOrEmpty(attachmentName))
            {
                _clonedSkin.AddAttachment(
                    slot.SlotIndex,
                    slot.Name,
                    slot.Attachment);
            }
            else if (sprite is null)
            {
                _clonedSkin.SetAttachment(
                    slot.SlotIndex,
                    attachmentName,
                    slot.Attachment);
            }
            else
            {
                var attachment = RemapAttachment(slot.Slot, sprite);
                _clonedSkin.SetAttachment(slot.SlotIndex, attachmentName, attachment);
            }
        }
예제 #2
0
        private bool TryGetSlotAndAttachment(
            string slotName,
            out SlotAndAttachment slotAndAttachment)
        {
            if (string.IsNullOrEmpty(slotName))
            {
                Debug.LogWarning($"Argument Null Or Empty: {nameof(slotName)}");
                slotAndAttachment = null;
                return(false);
            }

            var slot = SkeletonAnimation.skeleton.FindSlot(slotName);

            if (slot is null)
            {
                Debug.LogWarning($"Not Found Slot: {slotName}");
                slotAndAttachment = null;
                return(false);
            }

            var slotIndex = SkeletonAnimation.skeleton.FindSlotIndex(slotName);

            slotAndAttachment = new SlotAndAttachment(slotName, slot, slotIndex, slot.Attachment);
            return(true);
        }