- Home /
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
Answer by Addyarb · Jun 27, 2015 at 07:40 PM
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!
Thanks for the feedback and good idea with the script, I'll pop that in to give me the required behavior.
Your answer
Follow this Question
Related Questions
3rd party UI - World Canvas or Screen Space Camera? 0 Answers
Prefab not loaded in webplayer!? 2 Answers
Check if a player has Network View 0 Answers
Problem making a ruler 1 Answer
It is possible to have a Camera rect on TOP of a GUI 0 Answers