示例#1
0
    void ToggleTopMost()
    {
        bool isTop = !DataModel.Instance.Data.isTopMost;

        DataModel.Instance.Data.isTopMost = isTop;
        DataModel.Instance.SaveData();
        if (_pool.IsAnyRoleEnable())
        {
            SetWindowPos(windowHandle, isTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, 1 | 2);
        }
        _topmost.Image = isTop ? _enableImage : null;
    }
    private void LateUpdate()
    {
        // 判断当前是否有桌宠在场,没有则停止计算和渲染
        if (!_pool.IsAnyRoleEnable())
        {
            if (_camera.activeSelf)
            {
                _camera.SetActive(false);
                _window.SetBottom(true);
            }
            return;
        }
        else
        {
            if (!_camera.activeSelf)
            {
                _camera.SetActive(true);
                _window.SetBottom(false);
            }
        }

        if (!Input.GetMouseButton(1) && !Input.GetMouseButton(2))
        {
            CursorPenetrate();
        }

        if (_root == null)
        {
            return;
        }

        // 旋转中
        if (Input.GetMouseButton(1))
        {
            SetAA(false);
            Rotating();
        }
        // 缩放中
        if (_lastScroll != 0)
        {
            SetAA(false);
            Scaling();
        }

        // 拖动平移开始
        if (Input.GetMouseButtonDown(2))
        {
            SetAA(false);
            _screen2WorldOffset = GetScreen2WorldOffset();
        }
        // 拖动平移中
        if (Input.GetMouseButton(2))
        {
            Translation();
        }

        // 松开,保存
        if (Input.GetMouseButtonUp(1) ||
            Input.GetMouseButtonUp(2)
            // 使用上一帧的滚轮计算摄像机的位移并判断此帧为松手
            || (_lastScroll != 0 && Input.mouseScrollDelta.y == 0))
        {
            SetAA();
            DataModel.Instance.UpdateTransformData(_pool);
            DataModel.Instance.SaveData();
        }
        _lastScroll = Input.mouseScrollDelta.y;

        _ctaa.ctaaMat.SetFloat("_move", GetMouseMove());
    }