Exemple #1
0
    public void OnLeftButtonClick()
    {
        TextureHandler.LeftMask = TextureHandler.RenderTo2D(MaskTexture);

        var clones = GameObject.FindGameObjectsWithTag("clone");

        foreach (var clone in clones)
        {
            Destroy(clone);
        }
    }
        static float MeanIntensivity(RenderTexture renderTexture)
        {
            Texture2D texture = TextureHandler.RenderTo2D(renderTexture);

            Color[] pixels           = texture.GetPixels();
            int     blackpixelscount = 0;
            float   meanValue        = 0;

            for (int i = 0; i < pixels.Length; i++)
            {
                if (pixels[i].grayscale != 0)
                {
                    meanValue += pixels[i].grayscale;
                }
                else
                {
                    blackpixelscount++;
                }
            }
            meanValue = meanValue / (pixels.Length - blackpixelscount);
            return(meanValue);
        }