Наследование: UnityEngine.MonoBehaviour
Пример #1
0
        public void Initialize(bool overwrite = true)
        {
            if (overwrite || attachment == null)
            {
                // Get the applyPMA value.
                var skeletonComponent = GetComponent <ISkeletonComponent>();
                var skeletonRenderer  = skeletonComponent as SkeletonRenderer;
                if (skeletonRenderer != null)
                {
                    this.applyPMA = skeletonRenderer.pmaVertexColors;
                }
                else
                {
                    var skeletonGraphic = skeletonComponent as SkeletonGraphic;
                    if (skeletonGraphic != null)
                    {
                        this.applyPMA = skeletonGraphic.MeshGenerator.settings.pmaVertexColors;
                    }
                }

                // Subscribe to UpdateComplete to override animation keys.
                if (overrideAnimation)
                {
                    var animatedSkeleton = skeletonComponent as ISkeletonAnimation;
                    if (animatedSkeleton != null)
                    {
                        animatedSkeleton.UpdateComplete -= AnimationOverrideSpriteAttach;
                        animatedSkeleton.UpdateComplete += AnimationOverrideSpriteAttach;
                    }
                }

                spineSlot = spineSlot ?? skeletonComponent.Skeleton.FindSlot(slot);
                Shader attachmentShader = applyPMA ? Shader.Find(DefaultPMAShader) : Shader.Find(DefaultStraightAlphaShader);
                attachment = applyPMA ? sprite.ToRegionAttachmentPMAClone(attachmentShader) : sprite.ToRegionAttachment(SpriteAttacher.GetPageFor(sprite.texture, attachmentShader));
            }
        }
Пример #2
0
        public void Attach()
        {
            var skeletonComponent = GetComponent <ISkeletonComponent>();
            var skeletonRenderer  = skeletonComponent as SkeletonRenderer;

            if (skeletonRenderer != null)
            {
                this.applyPMA = skeletonRenderer.pmaVertexColors;
            }
            else
            {
                var skeletonGraphic = skeletonComponent as SkeletonGraphic;
                if (skeletonGraphic != null)
                {
                    this.applyPMA = skeletonGraphic.MeshGenerator.settings.pmaVertexColors;
                }
            }

            Shader attachmentShader = applyPMA ? Shader.Find(DefaultPMAShader) : Shader.Find(DefaultStraightAlphaShader);

            attachment = applyPMA ? sprite.ToRegionAttachmentPMAClone(attachmentShader) : sprite.ToRegionAttachment(SpriteAttacher.GetPageFor(sprite.texture, attachmentShader));
            skeletonComponent.Skeleton.FindSlot(slot).Attachment = attachment;
        }