1
Misc Archive / Sprite Button Scale
« on: July 10, 2015, 03:58:54 PM »
Hello, hello, im writting cause i dunno where else to get the answer since i googles and tried everything.
See im doing a project and i did a prefab and instantiate the button. But when it does the scale its 1,1 and the prefab 50,50 how i change the scale? I tried but theres no documentation to change it. Here is the code, i would love to be able to set up scale and coordinates of the buttons... any suggestions?
See im doing a project and i did a prefab and instantiate the button. But when it does the scale its 1,1 and the prefab 50,50 how i change the scale? I tried but theres no documentation to change it. Here is the code, i would love to be able to set up scale and coordinates of the buttons... any suggestions?
- using UnityEngine;
- using System.Collections;
- public class ActionsButtons : MonoBehaviour {
- //actions needed
- public IAction action2;
- public IAction action3;
- public IAction action1;
- //if showed
- public bool showButtons;
- //send a mesage
- public string message;
- //buton id
- public int nextId;
- //prefab
- public GameObject btn1;
- //array where all the button would be
- public GameObject[] children;
- public void Start ()
- {
- //initialing array with 3 spaces for 3 buttons
- //finding the root UI
- GameObject parent = GameObject.Find("UIGUI");
- //child.name = "newbutton" + (nextId++);
- //loop than will fill each space with a button
- foreach(GameObject item in children)
- {
- //parents each button to the root
- GameObject child = NGUITools.AddChild(parent, btn1);
- //gives the name of each button
- child.name = "newbutton" + (nextId++);
- //child.transform.localScale = Vector3.one;
- }
- }
- }