Initialize() публичный Метод

public Initialize ( bool overwrite ) : void
overwrite bool
Результат void
Пример #1
0
        public static SkeletonGraphic AddSkeletonGraphicComponent(GameObject gameObject, Spine.Unity.SkeletonDataAsset skeletonDataAsset)
        {
            SkeletonGraphic graphic = gameObject.AddComponent <SkeletonGraphic>();

            if (skeletonDataAsset != null)
            {
                graphic.skeletonDataAsset = skeletonDataAsset;
                graphic.Initialize(false);
            }
            return(graphic);
        }
Пример #2
0
        public static SkeletonGraphic AddSkeletonGraphicComponent(GameObject gameObject, SkeletonDataAsset skeletonDataAsset)
        {
            SkeletonGraphic skeletonGraphic = gameObject.AddComponent <SkeletonGraphic>();

            if (skeletonDataAsset != null)
            {
                skeletonGraphic.skeletonDataAsset = skeletonDataAsset;
                skeletonGraphic.Initialize(overwrite: false);
            }
            return(skeletonGraphic);
        }
Пример #3
0
 static int Initialize(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Spine.Unity.SkeletonGraphic obj = (Spine.Unity.SkeletonGraphic)ToLua.CheckObject <Spine.Unity.SkeletonGraphic>(L, 1);
         bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
         obj.Initialize(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
        /// <summary>
        /// Initialize and instantiate the BoundingBoxFollowerGraphic colliders. This is method checks if the BoundingBoxFollowerGraphic has already been initialized for the skeleton instance and slotName and prevents overwriting unless it detects a new setup.</summary>
        public void Initialize(bool overwrite = false)
        {
            if (skeletonGraphic == null)
            {
                return;
            }

            skeletonGraphic.Initialize(false);

            if (string.IsNullOrEmpty(slotName))
            {
                return;
            }

            // Don't reinitialize if the setup did not change.
            if (!overwrite &&
                colliderTable.Count > 0 && slot != null &&                   // Slot is set and colliders already populated.
                skeletonGraphic.Skeleton == slot.Skeleton &&                 // Skeleton object did not change.
                slotName == slot.Data.Name                                   // Slot object did not change.
                )
            {
                return;
            }

            slot = null;
            currentAttachment     = null;
            currentAttachmentName = null;
            currentCollider       = null;
            colliderTable.Clear();
            nameTable.Clear();

            var skeleton = skeletonGraphic.Skeleton;

            if (skeleton == null)
            {
                return;
            }
            slot = skeleton.FindSlot(slotName);
            if (slot == null)
            {
                if (BoundingBoxFollowerGraphic.DebugMessages)
                {
                    Debug.LogWarning(string.Format("Slot '{0}' not found for BoundingBoxFollowerGraphic on '{1}'. (Previous colliders were disposed.)", slotName, this.gameObject.name));
                }
                return;
            }
            int slotIndex = slot.Data.Index;

            int requiredCollidersCount = 0;
            var colliders = GetComponents <PolygonCollider2D>();

            if (this.gameObject.activeInHierarchy)
            {
                var canvas = skeletonGraphic.canvas;
                if (canvas == null)
                {
                    canvas = skeletonGraphic.GetComponentInParent <Canvas>();
                }
                float scale = canvas != null ? canvas.referencePixelsPerUnit : 100.0f;

                foreach (var skin in skeleton.Data.Skins)
                {
                    AddCollidersForSkin(skin, slotIndex, colliders, scale, ref requiredCollidersCount);
                }

                if (skeleton.Skin != null)
                {
                    AddCollidersForSkin(skeleton.Skin, slotIndex, colliders, scale, ref requiredCollidersCount);
                }
            }
            DisposeExcessCollidersAfter(requiredCollidersCount);

            if (BoundingBoxFollowerGraphic.DebugMessages)
            {
                bool valid = colliderTable.Count != 0;
                if (!valid)
                {
                    if (this.gameObject.activeInHierarchy)
                    {
                        Debug.LogWarning("Bounding Box Follower not valid! Slot [" + slotName + "] does not contain any Bounding Box Attachments!");
                    }
                    else
                    {
                        Debug.LogWarning("Bounding Box Follower tried to rebuild as a prefab.");
                    }
                }
            }
        }