How to spawn prefab with script components on it?

I just used the prefab spawning example to spawn a prefab that had a component on it in the editor which is a Needle generated component. On spawn, the object doesn’t have the component on it. The prefab is referenced from the Unity Project Asset window and not the scene
https://engine.needle.tools/docs/scripting.html#assetreference-and-addressables

How can I keep the scripts on the prefab to be spawned?

Original Post on Discord

by user 103054507105067008

That’s exactly it. Is the script maybe unknown to the runtime / exporter? Do you get a log / warningf in the browser?

    if(GameObject.findObjectOfType(ARReticle) == null)
    {
        this.SpawnedReticule = await this.testReticle?.instantiate() as GameObject;
        console.log(this.SpawnedReticule.getComponent(ARReticle));
        //this.SpawnedReticule.addNewComponent(ARReticle);
    }

I just get ‘undefined’ in the console.log here in async start()

by user 103054507105067008

by user 103054507105067008

by user 103054507105067008

Its named ARReticule in unity

and you query for ARReticle

Ah I renamed it after and the script remained

by user 103054507105067008

D’oh moment

by user 103054507105067008