private void LoadAssetCacheDependenciesAsync <T>(BaseAssetCache Cache, LiteAction <bool> Callback = null) where T : UnityEngine.Object { var LoadCompletedCount = 0; var Dependencies = Cache.GetAllDependencies(); if (Dependencies == null || Dependencies.Length == 0) { Callback?.Invoke(true); return; } foreach (var Dependency in Dependencies) { var AssetPath = Dependency; var AssetType = GetAssetTypeWithName <T>(AssetPath); LoadAssetAsync <T>(AssetType, AssetPath, (IsLoaded) => { if (!IsLoaded) { Callback?.Invoke(false); return; } Cache.AddDependencyCache(AssetCacheList_[AssetPath]); LoadCompletedCount++; if (LoadCompletedCount >= Dependencies.Length) { Callback?.Invoke(true); } }); } }
private static IEnumerator CacheStreamingAssets(string[] FileList, LiteAction <int, int, int> Callback) { var Index = 0; var DoneCount = 0; var ErrorCount = 0; while (Index < FileList.Length) { yield return(CopyFileFromStreamingAssetsPathToPersistentDataPath(FileList[Index], (Suc) => { Index++; if (Suc) { DoneCount++; } else { ErrorCount++; } Callback?.Invoke(ErrorCount, DoneCount, FileList.Length); })); } Callback?.Invoke(ErrorCount, DoneCount, FileList.Length); }
public void CreatePrefabAsync(AssetUri Uri, LiteAction <UnityEngine.GameObject> Callback = null) { LoadAssetAsync <UnityEngine.GameObject>(AssetCacheType.Prefab, Uri.AssetPath, (IsLoaded) => { if (!IsLoaded) { Callback?.Invoke(null); return; } Callback?.Invoke(CreatePrefabSync(Uri)); }); }
public void CreateDataAsync(AssetUri Uri, LiteAction <byte[]> Callback = null) { LoadAssetAsync <UnityEngine.TextAsset>(AssetCacheType.Data, Uri.AssetPath, (IsLoaded) => { if (!IsLoaded) { Callback?.Invoke(null); return; } Callback?.Invoke(CreateDataSync(Uri)); }); }
public void CreateAssetAsync <T>(AssetUri Uri, LiteAction <T> Callback = null) where T : UnityEngine.Object { var AssetType = GetAssetTypeWithName <T>(Uri.AssetPath); LoadAssetAsync <T>(AssetType, Uri.AssetPath, (IsLoaded) => { if (!IsLoaded) { Callback?.Invoke(null); return; } Callback?.Invoke(CreateAssetSync <T>(Uri)); }); }
protected virtual void LoadAssetAsync <T>(AssetCacheType AssetType, string AssetPath, LiteAction <bool> Callback = null) where T : UnityEngine.Object { AssetPath = AssetPath.ToLower(); if (AssetCacheExisted(AssetPath)) { Callback?.Invoke(true); return; } if (!AssetLoadCallbackList_.ContainsKey(AssetPath)) { AssetLoadCallbackList_.Add(AssetPath, new List <LiteAction <bool> > { Callback }); LoadAssetCacheCompletedAsync <T>(AssetType, AssetPath, (IsLoaded) => { foreach (var LoadCallback in AssetLoadCallbackList_[AssetPath]) { LoadCallback?.Invoke(IsLoaded); } AssetLoadCallbackList_.Remove(AssetPath); }); } else { AssetLoadCallbackList_[AssetPath].Add(Callback); } }
public static void PlaySkeletonSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, LiteAction <SkeletonSfx> Callback, bool IsLoop = false, string AnimationName = "", LiteAction Finished = null) { if (Parent == null || Uri == null) { return; } if (string.IsNullOrWhiteSpace(AnimationName)) { AnimationName = Uri.AssetName; } AssetManager.CreatePrefabAsync(Uri, (Obj) => { var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(AnimationName, IsLoop, Finished); Sfx.Position = Position; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); Callback?.Invoke(Sfx); }); }
public void Foreach(LiteAction <T> TickFunc) { Flush(); InEach_++; foreach (var Item in Values_) { TickFunc?.Invoke(Item); } InEach_--; }
public static void AddClickEventToChild(Transform Parent, string ChildPath, LiteAction <EventSystemData> Callback, AssetUri AudioUri) { void OnClick(EventSystemData Data) { AudioManager.PlaySound(AudioUri); Callback?.Invoke(Data); } AddEventToChild(Parent, ChildPath, OnClick); }
protected override void LoadAssetAsync <T>(AssetCacheType AssetType, string AssetPath, LiteAction <bool> Callback = null) { AssetPath = AssetPath.ToLower(); if (!AssetBundlePathList_.Contains(AssetPath)) { Callback?.Invoke(false); return; } base.LoadAssetAsync <T>(AssetType, AssetPath, Callback); }
private void InternalUpdateItem(ItemEntity Entity, int Index) { if (Entity.Index == Index) { return; } Entity.Index = Index; Entity.ObjRectTrans.anchoredPosition = InternalGetItemPosition(Index); OnUpdateItem_?.Invoke(Index, Entity.Item); }
private static IEnumerator CopyFileFromStreamingAssetsPathToPersistentDataPath(string AssetBundlePath, LiteAction <bool> Callback) { var Uri = new Uri(Path.Combine(Application.streamingAssetsPath, AssetBundlePath)); using (var Request = new UnityWebRequest(Uri, "GET", (DownloadHandler) new DownloadHandlerBuffer(), (UploadHandler)null)) { yield return(Request.SendWebRequest()); if (Request.isNetworkError || Request.isHttpError) { LLogger.LWarning(Request.error); Callback?.Invoke(false); } else { if (Request.downloadHandler?.data == null) { LLogger.LWarning($"AssetBundle Data Is Null : {AssetBundlePath}"); Callback?.Invoke(false); } else { try { var TargetPath = Path.Combine(Application.persistentDataPath, AssetBundlePath); var DirectoryPath = PathHelper.GetDirectory(TargetPath); PathHelper.CreateDirectory(DirectoryPath); File.WriteAllBytes(TargetPath, Request.downloadHandler.data); Callback?.Invoke(true); } catch (LiteException Ex) { LLogger.LWarning(Ex.Message); Callback?.Invoke(false); } } } } }
private void LoadAssetCacheCompletedAsync <T>(AssetCacheType AssetType, string AssetPath, LiteAction <bool> Callback = null) where T : UnityEngine.Object { var Cache = CreateAssetCache <T>(AssetType, AssetPath); if (Cache == null) { Callback?.Invoke(false); return; } AssetCacheList_.Add(AssetPath, Cache); LoadAssetCacheDependenciesAsync <UnityEngine.Object>(Cache, (IsLoaded) => { if (!IsLoaded) { Callback?.Invoke(false); return; } TaskManager.AddTask(LoadAssetCacheAsync <T>(Cache), () => { Callback?.Invoke(true); }); }); }
public override void Tick(float DeltaTime) { if (!IsAlive) { return; } Time_ += DeltaTime; IsAlive = !IsEnd(); if (!IsAlive) { Finished_?.Invoke(); } }
public void ItemDone() { DoneCount_++; if (DoneCount_ >= ItemList_.Count) { IsEnd = true; Callback_?.Invoke(); return; } if (!IsParallel_) { ItemList_[DoneCount_].Execute(); } }
public static void LoadAsync(AssetUri Uri, LiteAction <bool> Callback) { if (!DataList_.ContainsKey(Uri.AssetName)) { AssetManager.CreateDataAsync(Uri, Buffer => { var Data = new DataTable(Uri.AssetName); var Succeeded = Data.Parse(Buffer); if (Succeeded) { DataList_.Add(Uri.AssetName, Data); } Callback?.Invoke(Succeeded); }); } }
public void Tick(float DeltaTime) { if (!IsMoving_) { return; } CurrentTime_ += DeltaTime; var T = CurrentTime_ / MoveTime_; Master_.localPosition = Vector3.Lerp(BeginPos_, EndPos_, Mathf.Clamp01(T)); if (T >= 1.0f) { Stop(); FinishCallback_?.Invoke(); } }
public void MoveTo(Vector3 TargetPos, float MoveTime, bool Force, LiteAction Finished) { if (IsMoving_ && !Force) { return; } if ((new Vector3(EndPos_.x, EndPos_.y) - TargetPos).magnitude < 0.00001f) { Finished?.Invoke(); return; } IsMoving_ = true; BeginPos_ = Master_.localPosition; EndPos_ = new Vector3(TargetPos.x, TargetPos.y, BeginPos_.z); MoveTime_ = Mathf.Clamp(MoveTime, 0.016f, float.MaxValue); CurrentTime_ = 0; FinishCallback_ = Finished; }
public IEnumerator Execute() { while (!IsEnd) { if (IsPause) { yield return(null); } else if (TaskEntity_ != null && TaskEntity_.MoveNext()) { yield return(TaskEntity_.Current); } else { IsEnd = true; } } Callback_?.Invoke(); }
public static void PlayParticleSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, LiteAction <ParticleSfx> Callback, bool IsLoop = false, LiteAction Finished = null) { if (Parent == null || Uri == null) { return; } AssetManager.CreatePrefabAsync(Uri, (Obj) => { var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(string.Empty, IsLoop, Finished); Sfx.Position = Position; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); Callback?.Invoke(Sfx); }); }
public override void Play(string AnimationName, bool IsLoop = false, LiteAction Finished = null) { if (Animation_.Skeleton.Data.FindAnimation(AnimationName) == null) { LLogger.LError($"can't play animation '{AnimationName}'"); return; } Animation_.AnimationState.SetAnimation(0, AnimationName, IsLoop); if (Finished == null) { Animation_.AnimationState.Complete = null; } else { Animation_.AnimationState.Complete = (Track) => { Finished.Invoke(); Animation_.AnimationState.Complete = null; }; } }
private void TriggerDispose(T Cache) { DisposeFunc_?.Invoke(Cache); }
private void TriggerRecycle(T Cache) { RecycleFunc_?.Invoke(Cache); }
private void TriggerSpawn(T Cache) { SpawnFunc_?.Invoke(Cache); }
public void Invoke() { Func_?.Invoke(Param_); }
public override void Enter() { Callback_?.Invoke(); }
public override void Execute() { NewFunc_?.Invoke(this, Param_); }
public virtual void Execute() { Func_?.Invoke(this); }