Exemple #1
0
        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);
            });
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public static ParticleSfx PlayParticleSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Vector2?Position = null, LiteAction Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return(null);
            }

            var Obj = AssetManager.CreatePrefabSync(Uri);
            var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform);

            SfxList_.Add(Sfx);
            Sfx.SetParent(Parent, false);
            Sfx.Play(string.Empty, IsLoop, Finished);
            Sfx.Position = Position ?? Vector2.zero;

            var order = UnityHelper.GetSortingOrderUpper(Parent);

            UnityHelper.AddSortingOrder(Obj, order + 1);

            return(Sfx);
        }
Exemple #4
0
        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);
            });
        }
Exemple #5
0
        public static ParticleSfx PlayParticleSfx(Transform Parent, AssetUri Uri, bool IsLoop = false, Action Finished = null)
        {
            if (Parent == null || Uri == null)
            {
                return(null);
            }

            var Obj = AssetManager.CreatePrefabSync(Uri);
            var Sfx = new ParticleSfx(Uri.AssetName, Obj.transform);

            SfxList_.Add(Sfx);
            Sfx.SetParent(Parent, false);
            Sfx.Play(string.Empty, IsLoop, Finished);
            Sfx.Position = Vector2.zero;

            var Canvas = UnityHelper.GetComponentUpper <Canvas>(Parent);

            if (Canvas != null && Canvas.overrideSorting)
            {
                UnityHelper.AddSortingOrder(Obj, Canvas.sortingOrder + 1);
            }

            return(Sfx);
        }
Exemple #6
0
        public static void PlayParticleSfxAsync(Transform Parent, AssetUri Uri, Vector2 Position, Action <ParticleSfx> Callback, bool IsLoop = false, Action 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 Canvas = UnityHelper.GetComponentUpper <Canvas>(Parent);
                if (Canvas != null && Canvas.overrideSorting)
                {
                    UnityHelper.AddSortingOrder(Obj, Canvas.sortingOrder + 1);
                }

                Callback?.Invoke(Sfx);
            });
        }