Quantcast
Viewing all articles
Browse latest Browse all 103

Unity Programmatically Link Prefab

Let's say I have 5 different enemy prefabs. I won't know until runtime which prefab I want to be spawning. I know that normally I can make a `public GameObject` variable that I can link to a script. What's the best way to link the prefab programmatically to accomplish this? It doesn't seem very efficient to have multiple variables for each prefab that I have to write boiler plate code to handle each :).

Viewing all articles
Browse latest Browse all 103

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>