Hi peeps, today i m testing on FB sdk, what i want to do is ... after i successfully logged in to fb, i want the game direct user to another scene.
Im going to teach you guys from scratch how to achieve this...but in a simplified way. from this tutorial, you will learn how to direct the first scene to second scene.
Steps:
1. Open Unity
2. Create new Scene
3. Save the first scene as "First_Scene"
4. Create a new script
Im going to teach you guys from scratch how to achieve this...but in a simplified way. from this tutorial, you will learn how to direct the first scene to second scene.
Steps:
1. Open Unity
2. Create new Scene
- Select "File" tab
- Select "New Scene"
- Click File tab
- Select "Save Scene as..."
4. Create a new script
- Go to "Asset" folder in "Project" explorer
- Right click, select "Create">"C# Script"
- Name the script as "OpenScene"
5. Write code in "OpenScene" script
- Write code as written in the image below, *warning : Unity is case sensitive, ensure all written properly.
- In this code we create a simple button, and labeled it with "Open Next Scenes"
- If the button is clicked, we load the next scene.
6. Add empty game object for first scene
- Click on "GameObject" tab
- Select "Create Empty"
- Name it as "OpenSceneObject"
7. Assign script to the "OpenSceneObject"
- Click on "OpenSceneObject" in Hierachy Editor
- View on Inspector window, click add component
- Select "Scripts">"OpenScene"
8. Create second scene
- Follow the same steps as creating the first scene, and name it as "SecondScene"
9. Create script for second scene
- Follow the same steps as creating the "OpenScene" script.
- Name the script as "SecondScene".
- Write the code for the "SecondScene" as below image:
- In this code we created a label displaying "Second scene" text.
10. Create second scene empty object
- Follow the same steps as creating the first scene empty object
- Name the object as "SecondScene"
11. Assign the "SecondScene script" to "SecondScene object"
- Follow the same steps as assigning the first script to first scene object.
12. Set the build setting in Second Scene.
- Click on SecondScene scene.
- Select "File" tab.
- Select "Build Settings".
- Select the Second_Scene.unity
- Click "add current" button.
13. Open the "First_Scene".
Comments
Post a Comment