- Home /
How do we access static prefabs?
Hi Friends,
How do we access static prefabs of the same kind in the scene through scripting?
Regards, vanhouten777.
Try to give more info and details and explain what you are doing.
Sir,
I am trying access static prefab trees and want to find the closest tree.
Regards, vanhouten777.
@vanhouten777: Ok, first off don't post such things as an answer!! Use comments or edit your question. I've converted your answer into a comment.
Second what the heck are "static prefab trees"? You have been asked to clarify your one line question, but this doesn't help in any way.
Prefabs are predefined GameObjects that resist in the project and they can be instantiated into the scene. Instantiated prefabs are usual objects like every other object in the scene. Only in the editor you still have the information of the prefab from which the object was instantiated. At runtime this isn't available.
Prefabs also can't be arranged in trees. A prefab can contain whole GameObject trees, but a prefab can't contain other prefabs.
So before anyone can answer your question you should explain detailed what you mean by "static prefab trees" and how you want to "access" them.
Sir,
I created a tree gameobject and created a empty prefab and dragged the tree game object to the empty prefab and used the tree prefab to place trees in the scene. Static prefab means the prefab was created during scene creation and not run time. Can we access tree prefab like arrays Tree[77] etc etc.
regards, vanhouten777.
Do we have to use instance manager?
regards, vanhouten777
Answer by Bunny83 · Feb 12, 2012 at 01:42 PM
Ok, i think i get what you want (at least it's a bit more clear now). So you talk about Unity's terrain engine and the tree-detail prefabs.
The TerrainData of your terrain script contains everything about the terrain. I guess you want either:
TerrainData.treePrototypes which returns the list of prototypes / prefabs you can place on the terrain.
TerrainData.treeInstances which returns the list of all tree instances you've placed on the terrain (of course at edit-time).
Your answer