- Home /
              This question was 
             closed Sep 13, 2015 at 01:51 PM by 
             InsertNamehere for the following reason: 
             
 
            The question is answered, right answer was accepted
 
               Question by 
               InsertNamehere · Sep 13, 2015 at 02:11 PM · 
                c#instantiateparentparent-child  
              
 
              SetParent help.
Hello guys. I'm working on a 2D game for android. And i have found a big annoying problem. My problem is, when i spawn my UI Image and parent it to my canvas it doesn't scale it self. If i put it like a prefab it scales but instantiate doesn't scale it. I've found some answers about SetParent etc. but i couldn't get it working. If you guys can help me i would really appericiate. THANKS!
 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class Spawner : MonoBehaviour {
 
     public GameObject[] Images;
     public float timer;
     public bool FirstPlay; //if true, timer will be reduced to start faster.
 
     //Adjust Timer
     void Start()
     {
         if (FirstPlay)
         {
             timer = 2;
         }
 
         else
         {
             timer = 5;
         }
     }
 
     //Start Spawning
     void Update()
     {
         timer -= 1 * Time.deltaTime;
         if(timer <= 0) { 
         GameObject Spawn = (GameObject)Instantiate(Images[Random.Range(0, Images.Length)], transform.position, transform.rotation);
             Spawn.transform.SetParent(gameObject, false);
             timer = 5;
         
         }
     }
 
 
 }
 
               Comment
              
 
               
               koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                