WHY won't this instantiate as a child of my canvas?!

Edit: got it. A simple google search helps… Sorry folks…

I’m tearing my hair out missing something simple I suppose… It pops up on play but in the root of the hierarchy. The console error is “Setting the parent of a transform which resides in a prefab is disabled to prevent data corruption.”

Here we go. Thanks folks!

using UnityEngine;

public class EnemyHealthController : MonoBehaviour
{
  
    public GameObject canvas;
    public GameObject enemyHealthBarPrefab;

    void Start()
    {
        Instantiate(enemyHealthBarPrefab);
        enemyHealthBarPrefab.transform.SetParent(canvas.transform, true);
    }
}

You’re attempting to set the transform of the prefab, not the transform of the instantiated object.

–Eric