| | |
| | | |
| | | protected GameObject spineContainer; |
| | | |
| | | protected SkeletonGraphic spineComp; |
| | | protected SkeletonAnimation spineComp; |
| | | protected Spine.AnimationState spineAnimationState; |
| | | |
| | | public GameObjectPoolManager.GameObjectPool pool; |
| | |
| | | } |
| | | |
| | | // 初始化spine组件 |
| | | if (effectConfig != null && effectConfig.isSpine != 1) |
| | | if (effectConfig != null && effectConfig.isSpine != 0) |
| | | { |
| | | GameObject spineContainerPrefab = ResManager.Instance.LoadAsset<GameObject>("UIComp", "SpineContainer"); |
| | | spineContainer = GameObject.Instantiate(spineContainerPrefab, transform); |
| | | GameObject spineContainerPrefab = ResManager.Instance.LoadAsset<GameObject>("UIComp", "SpineAnimContainer"); |
| | | spineContainer = GameObject.Instantiate(spineContainerPrefab, transform, true); |
| | | spineContainer.transform.localPosition = Vector3.zero; |
| | | } |
| | | // 有特效可能带spine又带unity特效的情况 |
| | | spineComp = gameObject.GetComponentInChildren<SkeletonGraphic>(true); |
| | | spineComp = gameObject.GetComponentInChildren<SkeletonAnimation>(true); |
| | | } |
| | | |
| | | protected virtual void Clear() |
| | |
| | | |
| | | public virtual void Play(bool showLog = true) |
| | | { |
| | | |
| | | |
| | | if (!isInit) |
| | | { |
| | | InitComponent(showLog); |
| | | isInit = true; |
| | | } |
| | | else |
| | | { |
| | | //避免重复创建 |
| | | if (!this.gameObject.activeSelf) |
| | | { |
| | | this.gameObject.SetActive(true); |
| | | InitComponent(showLog); |
| | | isInit = true; |
| | | } |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | //避免重复创建 |
| | | if (!this.gameObject.activeSelf) |
| | | { |
| | | this.gameObject.SetActive(true); |
| | | } |
| | | return; |
| | | } |
| | | |
| | | if (EffectMgr.IsNotShowBySetting(effectId)) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | // 如果delay小于等于0 那会立刻执行 |
| | | this.DelayTime(effectConfig.delayPlay, () => |
| | | { |
| | | PlayEffectInternal(); |
| | | }); |
| | | } |
| | | |
| | | protected void PlayEffectInternal() |
| | | { |
| | | if (effectConfig.isSpine != 0) |
| | | { |
| | | PlaySpineEffect(); |
| | |
| | | { |
| | | PlayUnityEffect(); |
| | | } |
| | | |
| | | } |
| | | |
| | | protected void PlaySpineEffect() |
| | |
| | | return; |
| | | } |
| | | |
| | | SkeletonDataAsset skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/BattleSpine/" + effectConfig.packageName, effectConfig.fxName); |
| | | SkeletonDataAsset skeletonDataAsset = ResManager.Instance.LoadAsset<SkeletonDataAsset>("UIEffect/" + effectConfig.packageName, effectConfig.fxName); |
| | | spineComp.skeletonDataAsset = skeletonDataAsset; |
| | | spineComp.Initialize(true); |
| | | spineComp.raycastTarget = false; |
| | | spineComp.timeScale = speedRate; |
| | | |
| | | spineAnimationState = spineComp.AnimationState; |
| | | spineAnimationState.Complete -= OnSpineAnimationComplete; |
| | | spineAnimationState.Complete += OnSpineAnimationComplete; |
| | | |
| | | |
| | | if (null == canvas) |
| | | canvas = GetComponentInParent<Canvas>(); |
| | | |
| | | // 添加特效穿透阻挡器 |
| | | blocker = spineComp.AddMissingComponent<EffectPenetrationBlocker>(); |
| | | |
| | | blocker.onSortingChanged = OnSortingChanged; |
| | | |
| | | // 如果没有canvas的话 正常是因为不在BattleWin下面的节点 意思就是当前没有显示 等到切回战斗的时候再通过BattleField.UpdateCanvas来更新 |
| | | if (canvas != null) |
| | | { |
| | | blocker.SetParentCanvas(canvas); |
| | | } |
| | | |
| | | spineComp.enabled = true; |
| | | |
| | | Spine.Animation animation = spineAnimationState.Data.SkeletonData.Animations.First(); |
| | | spineAnimationState.SetAnimation(0, animation, false); |
| | | spineAnimationState.SetAnimation(0, animation, effectConfig.isLoop != 0); |
| | | |
| | | SoundPlayer.Instance.PlayUIAudio(effectConfig.audio); |
| | | |
| | | } |
| | | |
| | | private bool CheckForAdditiveBlend(Spine.Skeleton skeleton) |
| | | { |
| | | // 遍历所有插槽,检查是否有相加模式 |
| | | foreach (var slot in skeleton.Slots) |
| | | { |
| | | if (slot.Data.BlendMode == Spine.BlendMode.Additive) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | protected void PlayUnityEffect() |
| | |
| | | // 添加特效穿透阻挡器 |
| | | blocker = effectTarget.AddMissingComponent<EffectPenetrationBlocker>(); |
| | | |
| | | blocker.onSortingChanged = OnSortingChanged; |
| | | |
| | | // 如果没有canvas的话 正常是因为不在BattleWin下面的节点 意思就是当前没有显示 等到切回战斗的时候再通过BattleField.UpdateCanvas来更新 |
| | | if (canvas != null) |
| | | { |
| | |
| | | |
| | | } |
| | | |
| | | void LateUpdate() |
| | | { |
| | | if (string.IsNullOrEmpty(sortingLayer)) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | OnSortingChanged(sortingLayer, sortingOrder); |
| | | } |
| | | |
| | | public string sortingLayer; |
| | | public int sortingOrder; |
| | | |
| | | protected void OnSortingChanged(string _sortingLayer, int _sortingOrder) |
| | | { |
| | | sortingLayer = _sortingLayer; |
| | | sortingOrder = _sortingOrder; |
| | | // 处理排序变化 |
| | | var renderers = spineComp.GetComponents<Renderer>(); |
| | | foreach (var renderer in renderers) |
| | | { |
| | | renderer.sortingLayerName = sortingLayer; |
| | | renderer.sortingOrder = sortingOrder; |
| | | } |
| | | } |
| | | |
| | | protected void OnDestroy() |
| | | { |
| | | if (onDestroy != null) |