Im simply trying to parent a prefab to a canvas, there no problem instantiating the object only when i parent via "SETPARENT" it breaks the scene; when i drag it in runtime to the canvas theres also no problem. Any ideas?
(The script is in the canvas object, the canvas is drag and set in the editor, i also try using gameobject but still wont work).
public static bool fightSwitch;
public GameObject party;
public Canvas canvas;
// Use this for initialization
void Start () {
fightSwitch = false;
}
// Update is called once per frame
void Update () {
if (fightSwitch == true) {
GetComponentInChildren().SetBool("Intro", true);
fightSwitch = false;
party = Resources.Load ("OBJECTS/PARTY") as GameObject;
Instantiate (party, transform.position, transform.rotation);
party.transform.SetParent (canvas.transform,false);
↧