Exemplo n.º 1
0
        private void AddTestButton(string testName, Vector2 position)
        {
            GameObject newButton = Instantiate(buttonPrefab);

            newButton.transform.SetParent(mContentRectTF, false);

            RectTransform rt = newButton.gameObject.GetComponent <Transform>() as RectTransform;

            rt.sizeDelta        = buttonSize;
            rt.anchoredPosition = position;

            SubtestButton button = newButton.GetComponent <SubtestButton>();

            if (button != null)
            {
                button.testOwner = this.testOwner;
                button.SetTest(testName);
            }

            Debug.Log("AddTestButton: testName=" + testName + " position=" + position);


            // SubtestButton button = Instantiate<SubtestButton>(buttonPrefab);
            // button.transform.SetParent(contentPanel, false);
            // button.SetTest(testName);

            // button.testOwner = this;
            // Debug.Log("DEBUG: AddTestButton: position=" + position);

            // RectTransform rt = button.gameObject.GetComponent<Transform>() as RectTransform;
            // rt.anchoredPosition = position;

            //UIHelper.SetUIObjectTopLeftPostion(button.gameObject, position);
        }
Exemplo n.º 2
0
//	private void CalculateButtonSize() {
//		float buttonPanelWidth = Screen.width;		// TODO: find the actual
//		int numButtonPerRow = 8;
//
//		buttonWidth = (buttonPanelWidth / numButtonPerRow) - buttonSpacing;
//		buttonHeight = (int)(buttonWidth * 0.4f);
//
//			Debug.Log("Screen.width=" + Screen.width);
//			Debug.Log("Screen.currentResolution=" + Screen.currentResolution);
//			Debug.Log("Screen.dpi=" + Screen.dpi);
//
//		Debug.Log("ButtonSize: " + buttonWidth + "," + buttonHeight);
//	}

        private void CreateSubtestButton(List <string> testList)
        {
            Vector2 position = new Vector3(5, -5);              // Top Left corner

            float contentWidth = referenceWidth - 20;           // TODO
            float spacing      = buttonSpacing;
            float rightBound   = contentWidth - spacing - 10;

            // Add Back
            SubtestButton backButton = Instantiate(subtestButtonPrefab,
                                                   Vector3.zero, Quaternion.identity);

            backButton.transform.SetParent(contentPanel, false);
            UIHelper.SetUIObjectTopLeftPostion(backButton.gameObject, position);
            backButton.SetTest("back");
            backButton.isBackButton = true;
            position.x += buttonWidth + spacing;

            // Debug.Log("DEBUG: ScreenWidth=" +contentWidth);
            // Add custom test

            foreach (string test in testList)
            {
                SubtestButton button = Instantiate(subtestButtonPrefab,
                                                   Vector3.zero, Quaternion.identity);
                button.transform.SetParent(contentPanel, false);
                button.SetTest(test);


                UIHelper.SetUIObjectTopLeftPostion(button.gameObject, position);

                button.testOwner = this;

                position.x += buttonWidth + spacing;

                //Debug.Log("DEBUG: position.x=" + position.x);

                if ((position.x + buttonWidth) >= rightBound)
                {
                    position.x  = 5;
                    position.y -= (buttonHeight + spacing);
                }

//
//			RectTransform rectTrans = button.GetComponent<RectTransform>();
//			rectTrans.anchorMax = new Vector2(0, 1);
//			rectTrans.anchorMin = new Vector2(0, 1);
//			rectTrans.localPosition = position;
//			button.GetComponent<RectTransform>().localPosition = position;
//
//			button.SetTest(test);
//
//			position.y -= 50;
            }
        }
Exemplo n.º 3
0
        private void AddTestButton(string testName, Vector2 position)
        {
            SubtestButton button = Instantiate(subtestButtonPrefab);

            button.transform.SetParent(contentPanel, false);
            button.SetTest(testName);

            button.testOwner = this;
            Debug.Log("DEBUG: AddTestButton: position=" + position);

            RectTransform rt = button.gameObject.GetComponent <Transform>() as RectTransform;

            rt.anchoredPosition = position;

            //UIHelper.SetUIObjectTopLeftPostion(button.gameObject, position);
        }