- Home /
Question by
jrudavicius · Jul 24, 2015 at 10:45 AM ·
scenelevel
How to load a different prefab using the same scene?
I am creating puzzle like game. I am using two scenes: one for choosing a level and second for the puzzle. I have got some puzzles as prefabs and I want to load a specific puzzle in puzzle scene if I press level button in level selection scene. I hope that the answer is clear and I want to know how to do it.
Comment
Answer by abi-kr01 · Jul 24, 2015 at 01:23 PM
you can use the "static" variable and record the user click value and load the certain prefab set according to that.
Example: say in scene 0 where i have a script called InputManager
public static string selected_level=0;
On Mouse click we put some value in selected_level
Void OnMouseDown()
{
selected_level=this.gameobject.name;
Application.loadlevel(1);
}
On the other scene we have some other script which will have
Void Start()
{
resources.load("prefab directory"+InputManager.selected_level,vector3(0,0,0),quterian.identity);
}
Your answer
Follow this Question
Related Questions
How to set a game-over scene when an object hits another? 0 Answers
Allow userto load custom unity levels/scenes. 2 Answers
Enter next level 1 Answer
Multiple Instances of My Current Scene? 0 Answers