I’ve been researching on this site and cannot find the exact error being replicated.
here is my loader method:
cloudv2 is an image inside Resources folder
clouds is a canvas
void Update () {
GameObject cl = Resources.Load("cloudv2") as GameObject;
cl.transform.SetParent(GameObject.Find("clouds").transform, false); //<<error on this line>>
}
here is the class inside cloudv2:
public GameObject cloud; // connected to cloudv2
void Start(){
cloud.transform.localScale = new Vector2 (2, 2);
cloud.transform.position = new Vector3 (Random.Range(-500, -400), Random.Range(-200, 200), 0);
}
void Update(){
cloud.transform.position = new Vector3 (cloud.transform.position.x + 1, cloud.transform.position.y, cloud.transform.position.z);
}
Error:
Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.
UnityEngine.Transform:set_parent(Transform)
cloudLoader:Update() (at Assets/cloudLoader.cs:17)
Any input is appreciated.