예제 #1
0
        public void ShowUI(System.Action <int> cbChangePage, System.Action <BaseResource> cbResource, System.Action cbClose = null)
        {
            if (isShowUI)
            {
                return;
            }

            isShowUI = true;


            cbClickChangePage = cbChangePage;
            cbClickResource   = cbResource;
            cbClickClose      = cbClose;

            // 放在视线位置
            Vector3 headPosition  = Camera.main.transform.position;
            Vector3 gazeDirection = Camera.main.transform.forward;
            float   scale         = 1;

            Vector3 pos = Vector3.zero;

            if (inputManager.FocusedObject != null)
            {
                float dis = Vector3.Distance(headPosition, inputManager.hitPoint);
                if (dis > 4)
                {
                    dis = 4;
                }

                pos = headPosition + gazeDirection * (dis - 0.3f);

                if (dis < 4)
                {
                    scale = dis / 4;
                }
            }
            else
            {
                pos = headPosition + gazeDirection * 4f;
            }
            gazeDirection.y = 0;

            ui.SetUISize(pos, gazeDirection, scale);


            ChangeUIData();

            ui.Show();

            ui.HideLoading();

            oldInputLayer          = inputManager.layerMask;
            inputManager.layerMask = LayerMask.GetMask("UI");
        }