예제 #1
0
    void Update()
    {
        float   tipHeight = transform.Find("Tip").transform.localScale.y;
        Vector3 tip       = transform.Find("Tip/TouchPoint").transform.position;

        whiteboard.SetPenSize(100);
        //Debug.Log(tip);

        if (lastTouch)
        {
            tipHeight *= 1.1f;
        }

        if (Physics.Raycast(tip, transform.up, out touch, tipHeight))
        {
            if (touch.collider.tag == "Whiteboard")
            {
                this.whiteboard = touch.collider.GetComponent <Whiteboard>();

                whiteboard.SetColor(myColor);
                whiteboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
                whiteboard.ToggleTouch(true);


                if (lastTouch == false)
                {
                    lastTouch = true;
                    lastAngle = transform.rotation;
                }
            }
            else if (touch.collider.tag == "Wallboard")
            {
                this.wallboard = touch.collider.GetComponent <WallBoard>();

                wallboard.SetColor(myColor);
                wallboard.SetTouchPosition(touch.textureCoord.x, touch.textureCoord.y);
                wallboard.ToggleTouch(true);


                if (lastTouch == false)
                {
                    lastTouch = true;
                    lastAngle = transform.rotation;
                }
            }
        }
        else
        {
            whiteboard.ToggleTouch(false);
            lastTouch = false;
        }


        if (lastTouch)
        {
            transform.rotation = lastAngle;
        }
    }