- Home /
Instantiating prefab of object like it was in the scene
Hello everyone! Does anyone know how I can use an object that I have placed in the scene for a prefab, delete it afterwards and instantiate the prefab exactly like the object has been in the beginning? Right now, I am trying to create a UI myself using some planes. When I try making a prefab of the planes and placing the prefabs into the scene, they will either lose their transform component or get their scale and rotation values assigned twice.
Does anyone know how to solve this? Any help would be great! Thank you very much in advance, Greetings, Shu
The issue is likely how you are Instantiating() the prefab. Please attach the code you use to Instantiate.
Hello robertbu! I am using the following code:
#pragma strict
var cloned_menu_item_02_blue : GameObject;
var menu_item_02_blue : GameObject;
var menu_item_02_blue_loc : Transform;
function Start () {
cloned_menu_item_02_blue = Instantiate(
menu_item_02_blue,
menu_item_02_blue_loc.position,
menu_item_02_blue_loc.rotation
);
}
Also, I should note that I assign the UI object to "var menu_item_02_blue : GameObject;" and the object where it is supposed to be instantiated for "var menu_item_02_blue_loc : Transform;".
Your answer
Follow this Question
Related Questions
Instantiated Object looses prefab's rotation 10 Answers
How to instantly move a newly instantiated prefab? 2 Answers
Instantiate a prefab results in a new prefab in a different location than expected 2 Answers
Having trouble instantiating a gameobject with rotation 0 Answers
Unity 3.4 Prefab Instance Rotation Issue 0 Answers