Example #1
0
    public void FinishPainting()
    {
        playerCharTransition.MakeTransition();
        DoneButton.SetActive(false);
        CameraController.camera.GetComponent <Es.InkPainter.Sample.MousePainter>().enabled = false;
        ReplayButton.SetActive(true);

        Texture texture = PaintWall.GetComponent <MeshRenderer>().materials[0].GetTexture("_BaseMap");

        RenderTexture.active = texture as RenderTexture;
        Texture2D tx = new Texture2D(texture.width, texture.height);

        tx.ReadPixels(new Rect(0, 0, tx.width, tx.height), 0, 0);
        tx.Apply();
        //Texture2D tx = texture as Texture2D;  // Texture2D.CreateExternalTexture(texture.width, texture.height, TextureFormat.RGBA32, true, false, texture.GetNativeTexturePtr());

        int redCount = 0;

        for (int x = 0; x < tx.width; x++)
        {
            for (int y = 0; y < tx.height; y++)
            {
                if (tx.GetPixel(x, y) == Color.red)
                {
                    redCount++;
                }
            }
        }
        float percent = redCount * 100 / (texture.width * texture.height);

        messager.ShowMessage("You've drawn " + percent + "% of the canvas", 10f);
        Debug.Log("You've drawn " + percent + "% of the canvas");
    }
 public void showMenu(Tile t)
 {
     MoveButton.SetActive(!t.currentUnit.moved);
     DoneButton.SetActive(t.currentUnit.moved);
     transform.position = t.transform.position + Vector3.right * 1.25f;
 }