Exemplo n.º 1
0
        /// <summary>
        /// 创建特效,当duration <= 0时,特效常驻
        /// </summary>
        protected void CreateSimpleEffect(string effectPath, string effectName, Transform parent, float duration = 0)
        {
            GameObject effect = null;
            GameObject prefab = LoadPrefab(effectPath, effectName);

            effect = Instantiate(prefab, parent, false);

            EffectContainer container = new EffectContainer(effect, null);

            EffectContainers.Add(container);
            container.Play(duration);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建特效,当duration <= 0时,特效常驻
        /// </summary>
        protected void CreateEffectFromPools(string effectPath, string effectName, Transform parent, float duration = 0)
        {
            Queue <GameObject> particles = null;
            GameObject         effect    = null;

            if (!EffectDic.TryGetValue(effectPath, out particles))
            {
                GameObject prefab = LoadPrefab(effectPath, effectName);
                particles = new Queue <GameObject>();

                effect = Instantiate(prefab, parent, false);
            }
            else
            {
                effect = particles.Dequeue();
                effect.transform.parent = parent;
            }

            EffectContainer container = new EffectContainer(effect, particles);

            EffectContainers.Add(container);
            container.Play(duration);
        }