123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System.Collections.Generic;
- using UnityEngine;
- namespace Core.UI.UTool.UITween
- {
- [System.Serializable]
- public class TweenAssetGrpupInfo
- {
- [HideInInspector] public bool Foldout;
- public bool isActive;
- public string animName;
- public bool isLoop;
- public List<Object> allTargets = new List<Object>();
- public TweenAssetInfo TweenAssetInfo;
- public bool TargetFoldout = true;
- public float maxDuration;
- public bool isUpdate;
- [HideInInspector] public float currTime;
- // public List<TweenEntity> allTweenInfo = new List<TweenEntity>();
- public void StartPlay()
- {
- if (TweenAssetInfo == null)
- {
- return;
- }
- maxDuration = 0;
- for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
- {
- TweenEntity tweenEntity = TweenAssetInfo.allTweenInfo[i];
- if (tweenEntity.duration + tweenEntity.delay > maxDuration)
- {
- maxDuration = tweenEntity.duration + tweenEntity.delay;
- }
- tweenEntity.Prepare();
- tweenEntity.Rest(allTargets[i]);
- }
- isUpdate = true;
- currTime = 0;
- }
- public void SetMaxTime()
- {
- maxDuration = 0;
- if (TweenAssetInfo == null)
- {
- return;
- }
- for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
- {
- TweenEntity tweenEntity = TweenAssetInfo.allTweenInfo[i];
- if (tweenEntity.duration + tweenEntity.delay > maxDuration)
- {
- maxDuration = tweenEntity.duration + tweenEntity.delay;
- }
- }
- }
- public void JumpToTime(float t)
- {
- if (TweenAssetInfo == null)
- {
- return;
- }
- for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
- {
- TweenAssetInfo.allTweenInfo[i].Prepare();
- // allTweenInfo[i].Rest();
- }
- PlayTween(t, true);
- }
- public void PlayTween(float t, bool isFallBack)
- {
- if (TweenAssetInfo == null)
- {
- return;
- }
- if (isLoop)
- {
- t %= maxDuration;
- }
- for (int i = 0; i < TweenAssetInfo.allTweenInfo.Count; i++)
- {
- TweenAssetInfo.allTweenInfo[i].Play(allTargets[i], t, isFallBack);
- }
- }
- }
- }
|