Exemple #1
0
    private void Update()
    {
        //if (collision.collider.tag == "WritableSurface")
        //{
        // send a raycast out to the whiteboard
        Vector3 dir;

        if (isEraser)
        {
            dir = -transform.up;
        }
        else
        {
            dir = transform.right;
        }

        if (Physics.Raycast(transform.position, dir, out touchPos, 0.015f))
        {
            if (touchPos.collider.tag == "Whiteboard_Surface")
            {
                //Debug.Log("Hit Surface - " + touchPos.collider.gameObject.name);
                //pos.transform.position = touchPos.point;

                currentBoard = touchPos.collider.GetComponent <Whiteboard>();

                // generate texture blob with correct colour (basically an array of colours, the length of the number of pixels to be drawn)
                color = Enumerable.Repeat(penColor, penSize * penSize).ToArray();

                Debug.Log("Texture Coords: " + touchPos.textureCoord);
                currentBoard.UpdateTouching(true);
                currentBoard.UpdateWhiteboard(touchPos.textureCoord, color, penSize);
            }
            else
            {
                if (currentBoard != null)
                {
                    currentBoard.UpdateTouching(false);
                    currentBoard = null;
                }
            }
        }
        else
        {
            if (currentBoard != null)
            {
                currentBoard.UpdateTouching(false);
                currentBoard = null;
            }
        }
        // collision.gameObject.GetComponent<Whiteboard>().UpdateWhiteboard(this.transform.position,penColor, penSize);
        //}
    }