Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.

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.

I think you’re going to have to instantiate the cloudv2 and not Resources.Load it. I’ve never used Resources.Load on a prefab, but that would be my guess.

Look at how Unity is doing the GameObject here towards the bottom example.

And to clarify, Instantiate creates a clone. Resources.Load should be trying to reference the prefab, which is why you get the error.

thanks works