コード例 #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////
        /// Init helpers
        //////////////////////////////////////////////////////////////////////////////////////////////////////

        void Init_RT(int numberOfElements, RenderTextureFormat format, ref RenderTexture RT)
        {
            int   x, y;
            float u;

            if (GetTexDimension(numberOfElements, out x, out y, out u))
            {
                //Debug.Log("Init RT " + " X = " + x + " Y = " + y);
                if (RT == null)
                {
                    RT            = new RenderTexture(x, y, 0, format);
                    RT.filterMode = FilterMode.Point;
                    RT.Create();
                }
                else
                {
                    if (RT.width != x || RT.height != y)
                    {
                        Extension.ObjDestroy(RT);
                        RT            = new RenderTexture(x, y, 0, format);
                        RT.filterMode = FilterMode.Point;
                        RT.Create();
                    }
                    else
                    {
                        if (RT.IsCreated() == false)
                        {
                            RT.Create();
                        }
                        else
                        {
                            RT.DiscardContents();
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("Cannot init RT for " + RT + " with right dimension");
            }
        }