- Home /
How to set tag for gameobject created by VectorLine in runtime?
how to set a tag to the gameboject which created by VectorLine(using Vectorsity 1.4.2) before adding it into Hierarchy.
Answer by x_ivan_x@live.nl · Dec 09, 2013 at 09:04 PM
I presume you used the Instantiate function to spawn the object? if so then your code should look like this:
JS
var prefab: GameObject;
function SpawnObject()
{
var obj = Instantiate(prefab, transform.position, Quaternion.identity);
obj.gameObject.tag = "MainCamera";
}
C#
public GameObject prefab;
void SpawnObject()
{
GameObject obj = (GameObject) Instantiate(prefab, transform.position, Quaternion.identity);
obj.tag = "MainCamera";
}
And if you want to change the tag before spawning it you should change the prefab tag.
prefab.tag = "MainCamera";
Also make sure to assign the prefab in the inspector.
Line 19 ,there is the name of the mesh created by vectorline called "Spline" .When run the test ,at Hierarchy a new gameobject created by vectorline called "Vector Spline" which contains the mesh ,i mean how to access or change the tag of this gameobject before it comes into Hierrachy.
Answer by spamlab · Jan 02, 2014 at 06:22 PM
You can use vectorObject.
vectorline.vectorObject.gameObject.tag = "theTag";
Your answer
![](https://koobas.hobune.stream/wayback/20220613123752im_/https://answers.unity.com/themes/thub/images/avi.jpg)