コード例 #1
0
    void OnEnable()
    {
        m_pw = GetComponent <GPUParticleWorld>();
        if (m_camera == null || m_camera.Length == 0)
        {
            m_camera = new Camera[1] {
                Camera.main
            };
        }
        m_tmp_params = new CSTrailParams[1];

        m_max_entities       = m_pw.GetNumMaxParticles() * 2;
        m_buf_trail_params   = new ComputeBuffer(1, CSTrailParams.size);
        m_buf_trail_entities = new ComputeBuffer(m_max_entities, CSTrailEntity.size);
        m_buf_trail_history  = new ComputeBuffer(m_max_entities * m_trail_max_history, CSTrailHistory.size);
        m_buf_trail_vertices = new ComputeBuffer(m_max_entities * m_trail_max_history * 2, CSTrailVertex.size);

        if (m_act_render == null)
        {
            m_act_render = Render;
            foreach (var c in m_camera)
            {
                if (c == null)
                {
                    continue;
                }
                DSRenderer dsr = c.GetComponent <DSRenderer>();
                dsr.AddCallbackTransparent(m_act_render);
            }
        }
    }