Search Unity

SCRIPT REQ: Transition from one scene to another

Discussion in 'Scripting' started by DaveyJJ, Jun 1, 2005.

  1. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    I've yet to find a sample of a transition script ... a script to add to an object that will transition from one scene to the next with either any key touched or after a set amount of second. And it needs to face from screen to white (or a colour) then into the next one. Anyone?
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    At the moment you can only load levels in a player not in the editor.

    In the Build Player ... dialog you have to add multiple scenes.
    The first scene will be loaded when the player starts up.
    In this scene you add the following script to any object.
    Code (csharp):
    1.  
    2. // This will simply load the first level after 5 seconds
    3. yield new WaitForSeconds (5);
    4. Application.loadedLevel = 0;
    5.  
    This will work only in the player at the moment, which makes it a bit hard to use and test.

    I completely agree the interface for this is quirky at the moment. It will be simplified and we will make it so you can load levels in the editor as well.
    I will also add a fadeout while loading the level as you suggested.

    I don't think that will happen before unity 1.0 though.
     
  3. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    OK, I can wait.

    As an aside, my splash screen graphic, and graphic that goes in the dialogue box at start up, are 1024x768 and 432x163 pixels respectively which are not valid sizes for textures. How does one go about placing those ... should I use the splash screen as a texture (wrong size) in my 3D program just wrapped onto a plane and the plane facing the camera?

    Sorry to bug you guys at crunch time.
     
  4. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Take your splashscreen graphics which is 432x163 big.
    Add a border around it, so that the image becomes 512x256.
    Make sure that the actual splash screen graphic is centered.

    This should look as you expect it to.
    Write me a mail if it doesn't.
     
  5. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Done but there's an od error. I filed a bug report. It's not script related so I don't think this is the right forum. Let me know if you got the report!
     
  6. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Made this a script. Created scene with a textured plane (my splash screen). Positioned camera and light OK. Added this script to this plane object. Build Game added this new scene above my first one (so I have 0 and 1). Builds fine.

    Run as stabdalone you can see something happen at the five second mark but the 0 scene doesn't disappear at all. Scene "1" might be running behind it, I can't tell.
     
  7. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    Have you tried doing Application.loadedLevel = 1; instead?

    AFAICS, you simply reload the splash screen after 5 seconds....
     
  8. DaveyJJ

    DaveyJJ

    Joined:
    Mar 24, 2005
    Posts:
    1,558
    Now nothing seems to happen at the five second mark. Scene 0 loads then nothing happens.
     
  9. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The current behaviour is that everything in the first scene always stays.
    I totally agree it's a bitch to setup right now. I will change the interface to be much more intuitive for this after 1.0.

    For now, you will want to make a startup scene which contains only one game object with a script that loads the next level. Also make sure there is no camera in the first scene.

    On top of this there is a bug which makes your coroutine stop execution when loading a new scene. So you probably can't use coroutines for loading several scenes after each other.
    Use Update and Awake instead
    Code (csharp):
    1.  
    2. function Update () {
    3.    if (Input.GetKeyDown ("space"))
    4.    {
    5.       Application.loadedLevel = 1;
    6.    }
    7. }
    8. function Awake () {
    9.    Application.loadedLevel = 0;
    10. }
    11.  
     
  10. applejuices

    applejuices

    Joined:
    Nov 20, 2013
    Posts:
    80
    Okay, now I know. THanks
     
  11. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    This might be the oldest necro post ever on Unity Forums.

    Anyways most of this stuff is void as this was from 8 years ago.