예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (_active)
        {
            if (Input.GetMouseButtonUp(0))
            {
                _censoring = true;
                _active    = false;
            }
        }


        if (_censoring)
        {
            Vector3 pos = _camera.ScreenToWorldPoint(Input.mousePosition);
            if (_held)
            {
                _box.bottom = (int)pos.y;
                _box.left   = (int)pos.x;
                _box.UpdateBox();

                if (Input.GetMouseButtonUp(0))
                {
                    endX       = (pos.x - corner_x + dither.lastposx) * Mathf.Pow(2, dither.lastmipLevel);
                    endY       = (pos.y - corner_y + dither.lastposy) * Mathf.Pow(2, dither.lastmipLevel);
                    _held      = false;
                    _censoring = false;
                    rectanglesToCensor.Add(rectangle(startX, startY, endX, endY));
                    //Debug.Log( startX +" "+ startY +" "+ endX +" "+ endY);
                    dither.reDither();

                    _box.SetVisible(false);
                }
            }
            else
            {
                if (Input.GetMouseButtonDown(0))
                {
                    startX = (pos.x - corner_x + dither.lastposx) * Mathf.Pow(2, dither.lastmipLevel);
                    startY = (pos.y - corner_y + dither.lastposy) * Mathf.Pow(2, dither.lastmipLevel);
                    _held  = true;

                    _box.top    = (int)pos.y;
                    _box.right  = (int)pos.x;
                    _box.bottom = (int)pos.y;
                    _box.left   = (int)pos.x;
                    _box.UpdateBox();
                    _box.SetVisible(true);
                }
            }
            endX = pos.x;
            endY = pos.y;
        }
    }