Пример #1
0
 private Rect getRectFor(int index, float x, float y, TextAlignment align)
 {
     Texture2D background = this.GUISkins[0].box.normal.background;
     MockupCalc mockupCalc = new MockupCalc (2048, 1536);
     float width = (float)background.width;
     float height = (float)background.height;
     Rect result = mockupCalc.prAspectH (new Vector2 (x, y), width, height);
     if (align == TextAlignment.Center) {
         result.x -= result.width / 2f;
     }
     if (align == TextAlignment.Right) {
         result.x -= result.width;
     }
     return result;
 }
Пример #2
0
        public void OnGUI()
        {
            if (GetCurrentSceneIndex (GetCurrentSceneName()) == 1) {
                // Hide the selection indicator when the mouse moved.
                if (oldMousePosition != Input.mousePosition) {
                    oldMousePosition = Input.mousePosition;
                    shouldDrawSeletionIndicator = false;
                }

                // Draw the 'hovered' button image on the currently controller selected item.
                if (shouldDrawSeletionIndicator && selectedIndex > -1) {
                    GUIStyle style = this.GUISkins[selectedIndex].box;

                    MockupCalc mockupCalc = new MockupCalc (2048, 1536);
                    float x = mockupCalc.X (1000f);
                    float x2 = mockupCalc.X (1048f);
                    float y2 = mockupCalc.Y (348f);
                    float y3 = mockupCalc.Y (548f);
                    float y4 = mockupCalc.Y (748f);

                    switch (selectedIndex) {
                    case 0:
                        GUI.Box(getRectFor(0, x, y2, TextAlignment.Right),"",style);
                        break;
                    case 1:
                        GUI.Box(getRectFor(1, x, y3, TextAlignment.Right),"",style);
                        break;
                    case 2:
                        GUI.Box(getRectFor(2, x, y4, TextAlignment.Right),"",style);
                        break;
                    case 3:
                        GUI.Box(getRectFor(3, x2, y2, TextAlignment.Left),"",style);
                        break;
                    case 4:
                        GUI.Box(getRectFor(4, x2, y3, TextAlignment.Left),"",style);
                        break;
                    default:
                        break;
                    }
                }
            }
        }