instantiating and deleting prefabs

here’s my code to instantiate the inputbox object:
https://hastebin.com/wekibulube.cs

the vector3 line gives me an error “cannot convert from vector3 to transform.” the ide suggests making a method in which to put the code.

i have an actual prefab object called inputbox, which is i’m assuming required for this code operation. i’m trying to learn to be a better C#/Unity coder, so if you can give me conceptual advice along those lines that would be very helpful. i don’t really understand the code i used, but i would like to get to the point where i do understand it.

The Space Shooter tutorial teaches how to instantiate prefabs and destroy them: [Archived] Space Shooter - Unity Learn

1 Like

Check out all the available overloads for Instantiate. If you want to provide a position you also need to provide a rotation. Providing two arguments makes Unity think that you’re trying to pass in a parent.

Instantiate(inputBox, Vector3.zero, Quaternion.identity);
1 Like

edit2: here’s a solution: https://hastebin.com/canipaweyu.cs

okay Kelso, that worked. Anne, i will look at the tutorial. now i’m having an odd problem of the canvas lines showing at run time. what can i do about this? i googled but no luck.

edit: also, i have a script that’s supposed to store the value from an input field in a variable and then delete the prefab it’s a part of. this all happens after the enter button is pressed. currently, the script doesn’t work at all. and i can’t get at the inputfield to drag it onto the gameobject with my store and delete script (since i’m instantiating a clone of the prefab, and i can’t get at the intput field within the prefab). is there a way to do this?