How to attach a GameObject to a Prefab that has many scripts attached?
In my case the user can upload a 3D model (.fbx). Each uploaded model should contain the same scripts, in my case the scripts ensure that the user can rotate, scale and move the model. Das 3D Model soll erzeugt werden, sobald der Benutzer einen Button klickt.
Currently I have tried to create a prefab that contains all the required scripts. When you click the button, the corresponding .fbx model is attached as a gameobject as a child by this code:
public class Instantiation : MonoBehaviour
{
public GameObject MyObject;
public void Instantiate()
{
GameObject MaterialObject = Instantiate(MyObject, new Vector3(0, 0, 0), Quaternion.identity);
GameObject ConfigObject = Instantiate(Resources.Load<GameObject>("Prefabs/ModelConfigPrefabs/BasicConfigs"));
MaterialObject.transform.SetParent(ConfigObject.transform);
}
}
Unfortunately the output is faulty as you can see in this picture:
If everything is correct it should look like this:
The frame for the interactions should be adapted to the inserted object. I can reach this by directly attaching the GameObject to the Prefab but it should get generated because the user can upload every .fbx model.
How can i archive this? Im Using MRTK with Hololens 2 if this is rlevant.