Here is the situation: I have 10 weapons in my game, in main menu player may choose only two weapons that could take to the game, and this information about two weapons will save in a kind of "inventory". So the question is how I could instantiate only two objects from "inventory"?
Asked
Active
Viewed 50 times
0
-
You might find some useful inspiration in this past Q&A, about how to change what spawns in a level based on a choice a player made in a preceding menu scene. – DMGregory Sep 25 '22 at 17:33
-
@DMGregory Actually I found the solution by loading from Resource folder. But thanks for the answer, I will watch it. – Silz Sep 25 '22 at 17:38
-
@Dazzi If you figured out a solution yourself, then please post an answer to your own question and accept it. That way the question no longer appears as unanswered. – Philipp Sep 25 '22 at 17:45
1 Answers
0
I found the solution by loading from Resource folder.
GameObject weaponOne = Instantiate(Resources.Load("Gun1"), this.gameObject.transform) as GameObject;

Silz
- 37
- 7
-
1You may want to use Addressables rather than Resources. These are a more modern solution that scale better to bigger games. – DMGregory Sep 25 '22 at 17:54
-
@DMGregory it's mobile project and I like your solution, so need to know more about that – Silz Sep 25 '22 at 18:12
-
1
-