Search Unity

Creating several scenes and switching between them

Discussion in '2D' started by Sohaib_Alsafh, Jan 31, 2015.

  1. Sohaib_Alsafh

    Sohaib_Alsafh

    Joined:
    Jan 31, 2015
    Posts:
    6
    Hi,

    I would like to know how to create different scenes that users can switch between them using buttons (left and right). How do I do this?

    Thanks in advance :)
     
  2. paolo_lionhg

    paolo_lionhg

    Joined:
    Sep 5, 2013
    Posts:
    17
    this is very basic.

    ctrl + s, save scene to create them.

    use this to switch scenes. read everything written on this page.
    http://docs.unity3d.com/ScriptReference/Application.LoadLevel.html

    as for the buttons, it depends how you want to create them. you can use ongui, canvas, or raycast objects.

    i would highly suggest going through tutorials first before doing anything else.
     
    theANMATOR2b likes this.
  3. Sohaib_Alsafh

    Sohaib_Alsafh

    Joined:
    Jan 31, 2015
    Posts:
    6
    I will. Thanks a lot :)
     
  4. Sohaib_Alsafh

    Sohaib_Alsafh

    Joined:
    Jan 31, 2015
    Posts:
    6
    Dear Paolo,

    I have gone through the documents. But the thing I want is somewhat different and even more simple. I tried to find something about it but could not.

    What I want is to take the camera to another seen. As if you are flipping a page. As simple as that.

    Would you please recommend something :)
     
  5. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    if you will move camera in one scene, then use transform.position.
    add empty gameObjects, where the camera should be placed. Make c# script:

    //make array of cameraPoints:
    public Transform [] cameraPoint;
    //pointer to switch
    int pointer = 0;
    //move camera to first point
    void Start () {transform.position = cameraPoint [0];}
    //check if left or right are pressed:
    void Update () { if(Input.GetKeyDown(KeyCode.RightArrow))
    {pointer -= 1;
    //be sure, that pointer will not be -1
    if (pointer < 0) pointer =0;
    //move camera
    transform.position = CameraPoint [pointer];}
    }

    then make for left key as for right, but pointer +=1;
    Add it on camera. Fill array with drag&drop with your empty gameObjects.
    I didnot check it, but something like this should work :)