public static SkeletonSfx PlaySkeletonSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Vector2?Position = null, string AnimationName = "", LiteAction Finished = null) { if (Parent == null || Uri == null) { return(null); } if (string.IsNullOrWhiteSpace(AnimationName)) { AnimationName = Uri.AssetName; } var Obj = AssetManager.CreatePrefabSync(Uri); var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(AnimationName, IsLoop, Finished); Sfx.Position = Position ?? Vector2.zero; var order = UnityHelper.GetSortingOrderUpper(Parent); UnityHelper.AddSortingOrder(Obj, order + 1); return(Sfx); }
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 static SkeletonSfx PlaySkeletonSfx(Transform Parent, AssetUri Uri, string AnimationName = "", bool IsLoop = false, Action Finished = null) { if (Parent == null || Uri == null) { return(null); } if (string.IsNullOrWhiteSpace(AnimationName)) { AnimationName = Uri.AssetName; } var Obj = AssetManager.CreatePrefabSync(Uri); var Sfx = new SkeletonSfx(Uri.AssetName, Obj.transform); SfxList_.Add(Sfx); Sfx.SetParent(Parent, false); Sfx.Play(AnimationName, IsLoop, Finished); Sfx.Position = Vector2.zero; return(Sfx); }