| | |
| | | protected Spine.AnimationState spineAnimationState; |
| | | private GameObject instanceGO; |
| | | |
| | | private Action onComplete; |
| | | public Action onComplete; |
| | | public void Create(int _skinID, float scale = 0.8f, Action _onComplete = null, string motionName = "idle", bool isLh = false) |
| | | { |
| | | if (skinID == _skinID) |
| | | { |
| | | //避免重复创建 |
| | | |
| | | if (skeletonGraphic != null) |
| | | { |
| | | SetMaterialNone(); |
| | | if (isLh) |
| | | { |
| | | var skinConfigTmp = HeroSkinConfig.Get(skinID); |
| | | if (skinConfigTmp != null && skinConfigTmp.Tachie.Contains("SkeletonData")) |
| | | { |
| | | skeletonGraphic.enabled = true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | skeletonGraphic.enabled = true; |
| | | } |
| | | } |
| | | return; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | onComplete = _onComplete; |
| | | pool = GameObjectPoolManager.Instance.RequestPool(UILoader.LoadPrefab("UIHero")); |
| | | pool = GameObjectPoolManager.Instance.GetPool(UILoader.LoadPrefab("UIHero")); |
| | | |
| | | if (!transform.gameObject.activeSelf) |
| | | { |
| | |
| | | } |
| | | skeletonGraphic.Initialize(true); |
| | | |
| | | skeletonGraphic.enabled = true; |
| | | SetMaterialNone(); |
| | | spineAnimationState = skeletonGraphic.AnimationState; |
| | | spineAnimationState.Data.DefaultMix = 0f; |
| | | if (motionName == "") |
| | |
| | | /// <param name="motionName">动作名</param> |
| | | /// <param name="loop">循环</param> |
| | | /// <param name="replay">如果相同动作是否再次重播,比如跑步重播就会跳帧不顺滑</param> |
| | | public virtual void PlayAnimation(string motionName, bool loop = false, bool replay=true) |
| | | public virtual void PlayAnimation(string motionName, bool loop = false, bool replay = true) |
| | | { |
| | | if (spineAnimationState == null) return; |
| | | |
| | |
| | | } |
| | | |
| | | public void SetEnabled(bool isEnable) |
| | | { |
| | | { |
| | | if (skeletonGraphic == null) |
| | | { |
| | | return; |
| | | } |
| | | skeletonGraphic.enabled = isEnable; |
| | | } |
| | | |
| | | public void SetGray() |
| | | { |
| | | skeletonGraphic.material = MaterialUtility.GetDefaultSpriteGrayMaterial(); |
| | | } |
| | | public void SetMaterialNone() |
| | | { |
| | | skeletonGraphic.material = null; |
| | | } |
| | | } |