Author Topic: Sprite Button Scale  (Read 1732 times)

urich88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
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?

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ActionsButtons : MonoBehaviour {
  5.  
  6.         //actions needed
  7.         public IAction action2;
  8.         public IAction action3;
  9.         public IAction action1;
  10.         //if showed
  11.         public bool showButtons;
  12.         //send a mesage
  13.         public string message;
  14.         //buton id
  15.         public int nextId;
  16.         //prefab
  17.         public GameObject btn1;
  18.         //array where all the button would be
  19.         public GameObject[] children;
  20.  
  21.  
  22.  
  23.         public void Start ()
  24.         {
  25.                 //initialing array with 3 spaces for 3 buttons
  26.                 GameObject[] children = new GameObject[3];
  27.                 //finding the root UI
  28.                 GameObject parent = GameObject.Find("UIGUI");
  29.  
  30.  
  31.                 //child.name = "newbutton" + (nextId++);
  32.                 //loop than will fill each space with a button
  33.                 foreach(GameObject item in children)
  34.                 {
  35.                         //parents each button to the root
  36.                         GameObject child = NGUITools.AddChild(parent, btn1);
  37.                         //gives the name of each button
  38.                         child.name = "newbutton" + (nextId++);
  39.  
  40.                         //child.transform.localScale = Vector3.one;
  41.                 }
  42.  
  43.        
  44.  
  45.  
  46.  
  47.  
  48.  
  49.        
  50.         }
  51.  
  52.  
  53.         }
  54.  
  55.