private static int instanceCount = 0; // Number of FastGUIElement instances #endregion Fields #region Constructors // Atlas rectangle in pixels // Make a GUIElement and add to the ScrollWindow will immediately render public FastGUIElement( FastGUIScrollWindow scrollWindow, // Add this element to ScrollWindow Vector2 scrollWindowPos, // Position in window (origin is top-left) in pixels Rect atlasRect) : this(scrollWindowPos, atlasRect, Position.TOPLEFT) { scrollWindow.Add (this, scrollWindowPos); }
// Atlas rectangle for the pressed Button // Make a Button and add to the ScrollWindow, will immediately render public FastGUIButton( FastGUIScrollWindow scrollWindow, // Add this element to ScrollWindow Vector2 scrollWindowPos, // Position in window (origin is top-left) in pixels Rect atlasRect, // Atlas rectangle in pixels Rect atlasRectPressedButton) : base(scrollWindow, scrollWindowPos, atlasRect) { pressedButton = new FastGUIElement (scrollWindow, scrollWindowPos, atlasRectPressedButton); pressedButton.SetDisplayed (false); }
// Use this for initialization void Start () { play = new FastGUIElement ( new Vector2 (0, 0), // Screen position new Rect (0, 0, 2048, 768)); // Atlas position hScrollWindow = new FastGUIScrollWindow ( new Vector2 (0, play.height + 10), // Screen position new Rect (0, 768, 1024, 768), // Atlas position, window new Rect (0, 768, 2048, 768)); // Atlas position, total area levelIcon = new FastGUIElement ( hScrollWindow, new Vector2 (0, 0), // Position within ScrollWindow new Rect (0, 0, 128, 128)); // Atlas position vScrollWindow = new FastGUIScrollWindow ( new Vector2 (hScrollWindow.width, play.height + 10), // Screen position new Rect (0, 0, 1024, 768), // Atlas position, window new Rect (0, 0, 1024, 1536)); // Atlas position, total area levelIcon2 = new FastGUIElement ( vScrollWindow, new Vector2 (vScrollWindow.width - 128, 0), // Position within ScrollWindow new Rect (0, 0, 128, 128)); // Atlas position // Make the popup window popup = new FastGUIElement ( new Vector2 (2048*.75f, 1536*.75f), // Screen position new Rect (200, 0, 500, 400), // Atlas position FastGUIButton.Position.XYCENTRED); // Make and Add the button to go on it popupButton = new FastGUIButton ( new Vector2 (0, 0), // Screen position (will be ignored) new Rect (0, 0, 128, 128), // Atlas position new Rect (128, 0, 128, 128)); // Atlas position when pressed popup.Add (popupButton, new Vector2 (popup.width/2 - popupButton.width/2, popup.height/2 - popupButton.height/2)); // Hide it until ready popup.SetDisplayed (false); }