- Home /
How I can update prefab properties using c#
Hi, I need to update prefab's position trough script , I need to change the prefab's position properties not the position of a prefab's instance.
in the following rows that's what I want to do:
connect to sql db or XML and get my position value (x,y,z)
then use this values to update the prefab position --->> THAT'S WHAT I'M ASKING FOR!!
instantiate my prefab with new position.
I'm looking for a solution to update dinamically the prefab position for an AR application. Metaio SDk ovverride the position of a 3d object so trough scripting I can't update my gameObject position , I tried to update the position of my prefab and then Apply changes to my prefab and it works...so if someone know how to update prefab trough c# can solve my problem...
thanks in advance!
Answer by sniper43 · Jan 21, 2015 at 02:49 PM
connect to sql db or XML and get my position value (x,y,z)
then use this values to update the prefab position --->> THAT'S WHAT I'M ASKING FOR!!
instantiate my prefab with new position.
Here's some pseudocode:
Vector3 GetPosition(var[] parameters){
//return XML position
}
Update(){
Instantiate( prefab, GetPosition(parameters), prefab.transfrom.rotation );
}
You do not need to update your prefab's position, you need to modify where it's spawned. http://docs.unity3d.com/ScriptReference/Object.Instantiate.html
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Instantiating an Object doesn't use the given position. 1 Answer
Update character's position after animation 1 Answer
Check if player object is right above this object 1 Answer
Distribute terrain in zones 3 Answers