예제 #1
0
 private void LeftOrRight(Vector2 position)
 {
     if (Screen.width * 0.5f < position.x)//在屏幕右半边
     {
         UI.subUI.window.transform.SetAsFirstSibling();
         UI.buttonsArea.transform.SetAsLastSibling();
         Rect rectAgent  = ZetanUtility.GetScreenSpaceRect(itemAgent.GetComponent <RectTransform>());
         Rect rectWin    = ZetanUtility.GetScreenSpaceRect(UI.subUI.GetComponent <RectTransform>());
         Rect rectButton = ZetanUtility.GetScreenSpaceRect(UI.buttonsArea.GetComponent <RectTransform>());
         UI.window.transform.position = new Vector2(position.x - rectAgent.width * 0.5f - rectWin.width - rectButton.width, UI.window.transform.position.y);
     }
     else
     {
         UI.subUI.window.transform.SetAsLastSibling();
         UI.buttonsArea.transform.SetAsFirstSibling();
         Rect rectAgent  = ZetanUtility.GetScreenSpaceRect(itemAgent.GetComponent <RectTransform>());
         Rect rectWin    = ZetanUtility.GetScreenSpaceRect(UI.subUI.GetComponent <RectTransform>());
         Rect rectButton = ZetanUtility.GetScreenSpaceRect(UI.buttonsArea.GetComponent <RectTransform>());
         UI.window.transform.position = new Vector2(position.x + rectAgent.width * 0.5f + rectWin.width + rectButton.width, UI.window.transform.position.y);
     }
     ZetanUtility.KeepInsideScreen(UI.window.GetComponent <RectTransform>(), true, true, false, false);
 }