GUI canvas' WorldSpace camera not copied into prefab

I have a prefab of a door, within that door prefab is a GUI which is set up in World Space so it can been seen in front of the door.

The master copy I have for the prefab works as intended, it has the Render Mode set to “World Space” and the Event Camera assigned correctly.

The issue comes in any instances of that prefab I have added, they do not carry the assigned Event Camera, I have to assign it manually on each instance to get it to work.

Is this intended behavior, or am I doing something wrong with my prefab?

Thanks in advance

Hey there!

Sorry to hear you’re having issues with the canvas prefabs. As far as I can tell, this is the intended behavior of the canvas.

However, the Render Mode should remain as you set it.

An easy way to fix this would just be to create a temporary instance of it as you spawn it, and then set the camera there.

For instance:

public GameObject myCanvas; //Drag and drop your canvas prefab into the inspector.
	// Use this for initialization
	void Start () {
		GameObject canvas = Instantiate (myCanvas) as GameObject;
		canvas.GetComponent<Canvas> ().worldCamera = Camera.main;

Good luck!