Exemple #1
0
 public Console()
 {
     invalidState = true;
     messages     = new List <string>();
     consolePanel = Assist.LoadUI(UI_PREFAB);
     inputField   = Assist.FindComponent <InputField>(consolePanel, UI_INPUT_FIELD);
     textField    = Assist.FindComponent <Text>(consolePanel, UI_TEXT_OUTPUT);
 }
        public ViewControllerLogin()
        {
            panelView = Assist.LoadUI(PANEL_PREFAB_PATH);
            visible   = false;

            userInputField     = Assist.FindComponent <InputField>(panelView, "user_input");
            passwordInputField = Assist.FindComponent <InputField>(panelView, "password_input");
            loginButton        = Assist.FindComponent <Button>(panelView, "login_button");

            loginButton.onClick = new Button.ButtonClickedEvent();
            loginButton.onClick.AddListener(this.OnLoginButtonPressed);
        }
        public ViewControllerCreateAccount()
        {
            panelView = Assist.LoadUI(PANEL_PREFAB_PATH);
            visible   = false;

            email        = Assist.FindComponent <InputField>(panelView, "email");
            password     = Assist.FindComponent <InputField>(panelView, "password");
            createButton = Assist.FindComponent <Button>(panelView, "create_button");

            createButton.onClick = new Button.ButtonClickedEvent();
            createButton.onClick.AddListener(this.OnCreateButtonPressed);
        }
        public void Reload()
        {
            Clear();

            if (tableViewDataProvider == null)
            {
                return;
            }

            if (cellReference == null)
            {
                return;
            }

            // get parameters
            UITableViewParameters parameters = tableViewDataProvider.OnTableViewGetParameters(this);

            // Add mask
            if (mask == null)
            {
                mask = gameObject.AddComponent <Mask>();
            }

            float contentHeight = parameters.rows * cellReference.GetComponent <RectTransform>().rect.height;

            // Add scroll rect with content game object
            if (scrollRect == null)
            {
                scrollRect            = gameObject.AddComponent <ScrollRect>();
                scrollRect.horizontal = false;

                contentHolder = new GameObject();
                contentHolder.AddComponent <RectTransform>();

                contentHolder.GetComponent <RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, contentHeight);
                contentHolder.transform.SetParent(gameObject.transform, false);

                scrollRect.content = contentHolder.GetComponent <RectTransform>();

                tableVerticalScrollBar = Assist.FindComponent <Scrollbar>(gameObject, "Scrollbar");

                if (tableVerticalScrollBar)
                {
                    scrollRect.verticalScrollbar = tableVerticalScrollBar;
                }
            }

            if (cells == null)
            {
                cells = new List <UITableViewCell>();
            }

            // create cells
            for (int i = 0; i < parameters.rows; i++)
            {
                GameObject cell = Instantiate(cellReference) as GameObject;

                cell.SetActive(true);
                cell.transform.SetParent(contentHolder.transform, false);

                UITableViewCell cellComponent = cell.GetComponent <UITableViewCell>();

                cellComponent.row            = i;
                cellComponent.buttonDelegate = this;

                tableViewDataProvider.OnTableViewSetupCell(this, cellComponent);

                cells.Add(cellComponent);
            }

            // Align cells, in screen cords
            {
                RectTransform tableViewTransform = gameObject.GetComponent <RectTransform>();

                Vector3 pos = tableViewTransform.position + new Vector3(0.0f, contentHeight * 0.5f, 0.0f);

                int i = 0;

                float tableWidth = tableViewTransform.rect.width;

                float scrollbarOffset = tableVerticalScrollBar != null?tableVerticalScrollBar.GetComponent <RectTransform>().rect.width : 0.0f;

                foreach (UITableViewCell c in cells)
                {
                    RectTransform rc = c.gameObject.GetComponent <RectTransform>();

                    if (i == 0)
                    {
                        pos -= new Vector3(0.0f, rc.rect.height * 0.5f, 0.0f);
                    }
                    else
                    {
                        pos -= new Vector3(0.0f, rc.rect.height, 0.0f);
                    }

                    i++;

                    rc.position = pos - new Vector3(scrollbarOffset * 0.5f, 0.0f, 0.0f);
                    rc.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, tableWidth - scrollbarOffset);
                }
            }

            // disable original cell
            cellReference.SetActive(false);

            // Vertical scroll bar should be first
            if (tableVerticalScrollBar)
            {
                tableVerticalScrollBar.transform.SetAsLastSibling();
            }
        }