I’m creating an GameObject instance from a fbx model in the editor with the following code snippet:
static void CreateObject(ObjectInfo info)
{
GameObject at;
if (GameObject.Find("AtTree") == null)
{
at = new GameObject("AtTree");
at.transform.position = new Vector3(0, 0, 0);
}
else
{
at = GameObject.Find("AtTree");
}
GameObject root = new GameObject(info.Name);
root.transform.parent = at.transform;
root.AddComponent<Attachable>();
GameObject tmp = AssetDatabase.LoadAssetAtPath<GameObject>(FILEDIR + info.Name + ".fbx");
GameObject mod = Instantiate(tmp, root.transform, true);
mod.transform.position = new Vector3(0, 0, 0);
mod.transform.localScale = new Vector3(100, 100, 100);
Instantiate(mod);
}
This creates the GameObject I want (blue), but also an additional object (red)
The blue object is the one I want to keep, but I don’t want the red one. How can I remove the red one or create the blue one without creating the red one at all?