- Home /
Changing tag not working in batchmode
Hi there I have an editor script that searches through the children of a GameObject and once the correct ones are found it changes their tag. This works perfectly when running it manually via the UI while Unity is open but it doesn't work when running Unity via batchmode.
Here is my command line string:
-projectPath "unityProjectLocation" -quit -batchmode -executeMethod Class.Method
Here is the code in question:
GameObject test = AssetDatabase.LoadAssetAtPath("Assets/Resources/model.fbx", typeof(GameObject)) as GameObject;
if (test != null)
Debug.Log("fbx found");
Stack<Transform> childrenStack = new Stack<Transform>();
childrenStack.Push(test.transform);
bool aDone = false, bDone = false;
while (childrenStack.Count > 0)
{
Transform currentChild = childrenStack.Pop();
if (currentChild.name.Contains("NameToSearchForA"))
{
currentChild.tag = "NameA";
aDone = true;
Debug.Log("aDone");
}
else if (currentChild.name.Contains("NameToSearchForB"))
{
currentChild.tag = "NameB";
bDone = true;
Debug.Log("bDone");
}
else if (currentChild.childCount == 0)
{
continue;
}
else
{
for (int i = 0; i < currentChild.childCount; i++)
childrenStack.Push(currentChild.GetChild(i));
}
if (aDone && bDone)
break;
}
Is there something I'm missing? I'm pretty sure there is something else loaded when a user opens Unity compared to running it via batchmode but I can't seem to find out what or if it is even possible.
Also this needs to be done via batchmode as we process files on our server. Thanks
Your answer
![](https://koobas.hobune.stream/wayback/20220612194043im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom editor tags not saving 1 Answer
LightProbe comparsion 0 Answers
Remove or disable an EditorGUILayout.PropertyField 0 Answers
Trouble setting the object reference in a property drawer 0 Answers