Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
            });
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
            });
        }