예제 #1
0
        public void RecycleAllRenderEffects()
        {
            var enumerator = m_nodes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                RenderEffectNode node = enumerator.Current.Value;
                for (int i = 0; i < node.m_render_effects.Count; ++i)
                {
                    RenderEffectInfo info   = node.m_render_effects[i];
                    RenderEffectData config = GetRenderWorld().GetRenderEffectData(info.m_render_effect_cfgid);
                    if (info.m_task != null)
                    {
                        RenderTask.Recycle(info.m_task);
                        info.m_task = null;
                    }
                    if (info.m_go != null)
                    {
                        info.m_go.transform.parent = null;
                        UnityResourceManager.Instance.RecycleGameObject(config.m_prefab, info.m_go);
                        info.m_go = null;
                    }
                    node.m_render_effects.RemoveAt(i);
                    RecyclableObject.Recycle(info);
                }
            }
        }
예제 #2
0
        protected override void OnDestruct()
        {
            var enumerator = m_nodes.GetEnumerator();

            while (enumerator.MoveNext())
            {
                RenderEffectNode node = enumerator.Current.Value;
                for (int i = 0; i < node.m_render_effects.Count; ++i)
                {
                    RecycleRenderEffectInfo(node.m_render_effects[i], null);
                }
            }
            m_nodes.Clear();
        }
예제 #3
0
        public void PlayRenderEffect(int render_effect_cfg_id, FixPoint play_time)
        {
            //ZZWTODO 为了精准识别每一个effect,可以考虑在逻辑端生成一个id
            RenderEffectData config = GetRenderWorld().GetRenderEffectData(render_effect_cfg_id);

            if (config == null)
            {
                return;
            }
            RenderEffectNode node;

            if (!m_nodes.TryGetValue(config.m_binding, out node))
            {
                string path;
                if (!m_binding_name_to_path.TryGetValue(config.m_binding, out path))
                {
                    return;
                }
                ModelComponent model_component = ParentObject.GetComponent(ModelComponent.ID) as ModelComponent;
                if (model_component == null)
                {
                    return;
                }
                Transform tr = model_component.GetUnityGameObject().transform.FindChild(path);
                if (tr == null)
                {
                    return;
                }
                node                      = new RenderEffectNode();
                node.m_parent_tr          = tr;
                m_nodes[config.m_binding] = node;
            }
            //RenderEffectInfo info = null;
            //for (int i = 0; i < node.m_render_effects.Count; ++i)
            //{
            //    if (node.m_render_effects[i].m_render_effect_cfgid == render_effect_cfg_id)
            //    {
            //        info = node.m_render_effects[i];
            //        break;
            //    }
            //}
            //if (info != null)
            //{
            //}
            GameObject effect_go = UnityResourceManager.Instance.CreateGameObject(config.m_prefab);

            if (effect_go == null)
            {
                return;
            }
            effect_go.transform.parent           = node.m_parent_tr;
            effect_go.transform.localPosition    = Vector3.zero;
            effect_go.transform.localScale       = Vector3.one;
            effect_go.transform.localEulerAngles = Vector3.zero;
            RenderEffectInfo info = RecyclableObject.Create <RenderEffectInfo>();

            info.m_render_effect_cfgid = render_effect_cfg_id;
            info.m_go = effect_go;
            if (play_time > FixPoint.Zero)
            {
                var task_scheduler          = GetRenderWorld().GetTaskScheduler();
                RemoveRenderEffectTask task = RenderTask.Create <RemoveRenderEffectTask>();
                task.Construct(this, render_effect_cfg_id);
                task_scheduler.Schedule(task, GetRenderWorld().CurrentTime, play_time);
                info.m_task = task;
            }
            node.m_render_effects.Add(info);
        }