Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change scene when object is grabbed. #4

Open
ghost opened this issue Jan 19, 2019 · 1 comment
Open

Change scene when object is grabbed. #4

ghost opened this issue Jan 19, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Jan 19, 2019

Hello all, I've a question:

Is it possible to go to another scene when you grab a object with your controller? I've seen in the test scene in the inspector that there's a "On Grabbed" section (picture) where you can select scenes. I've tried that, but no success. Can anyone help me with this. I'm new to programming and Unity so I don't really know how to do this. (I'm on the Oculus Go.)
picture of inspector

@ghost ghost changed the title Change scene when something is grabbed. Change scene when object is grabbed. Jan 19, 2019
@ghost ghost closed this as completed Jan 19, 2019
@ghost ghost reopened this Jan 19, 2019
@nothingAD
Copy link

Hey @Robbin12392

yes it is possible and not that complicated. First you need a class with a public method containing the SceneManager.LoadScene()
Make sure you use UnityEngine.SceneManagment on top of you script and don't forget to drag the scene you want to load into you Build Settings.
After this is done, go to the grabbable component and click the + on the event you want to load the next scene. Now just drag the SceneLoader Component into the slot an select the LoadScene() Method.
Everything should look like this.

Hope this helps!
Best regards

sceneload

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{
    //make a public method
    public void LoadScene()
    {
        //Dont forget to put the scene into the build settings
        // than take the index to load scene 1
        SceneManager.LoadScene(1);

        // or you can use a string to load a new scene

        //SceneManager.LoadScene("name-of-scene", LoadSceneMode.Single);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant