Ejemplo n.º 1
0
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get(profilerTag);

            if (isFirstRender)
            {
                cmd.SetGlobalVectorArray("_RunningWaterData", new Vector4[1000]);
                isFirstRender = false;
            }

            List <RunningWater2D> runningWaters    = RunningWaterSystem2D.Get();
            List <Vector4>        runningWaterData = new List <Vector4>(runningWaters.Count);

            for (int i = 0; i < runningWaters.Count; i++)
            {
                Vector2 pos    = renderingData.cameraData.camera.WorldToScreenPoint(runningWaters[i].transform.position);
                float   radius = runningWaters[i].GetRadius();
                runningWaterData.Add(new Vector4(pos.x, pos.y, radius, 0.0f));
            }

            if (runningWaterData.Count > 0)
            {
                cmd.SetGlobalInt("_RunningWaterCount", runningWaters.Count);
                cmd.SetGlobalVectorArray("_RunningWaterData", runningWaterData);
                cmd.SetGlobalFloat("_OutlineSize", outlineSize);
                cmd.SetGlobalColor("_InnerColor", innerColor);
                cmd.SetGlobalColor("_OutlineColor", outlineColor);
                cmd.SetGlobalFloat("_CameraSize", renderingData.cameraData.camera.orthographicSize);

                cmd.Blit(source, source, material);

                context.ExecuteCommandBuffer(cmd);
            }

            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }
Ejemplo n.º 2
0
 private void Awake()
 {
     collider = GetComponent <CircleCollider2D>();
     RunningWaterSystem2D.Add(this);
 }
Ejemplo n.º 3
0
 private void OnDestroy()
 {
     RunningWaterSystem2D.Remove(this);
 }