Search Unity

...from one Map-level to open second Map-Level ...

Discussion in 'Getting Started' started by boshko, Feb 19, 2015.

  1. boshko

    boshko

    Joined:
    Jan 22, 2015
    Posts:
    20
    Coz im begginer,,, How to setup to: from one Map-level to open second Map-Level with click on one button? Probably some thing with coding, right? Or maybe somehow using this UI tools?
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    You can use the UI tools to make the button, but you'd need a simple script to wire the button up to, yes. The script can be very simple and just call Application.LoadLevel.
     
    boshko likes this.
  3. bigSadFace

    bigSadFace

    Joined:
    Aug 18, 2014
    Posts:
    116
    As superpig said, you will need a very simple script and then you can call the function using the gui. I attach a screenshot and some code to show this. Please note the level is set using the inspector as a public variable.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ButtonLoadLevel : MonoBehaviour
    5. {
    6.  
    7.  
    8.         public int level;
    9.  
    10.         public void Click ()
    11.         {
    12.  
    13.                 //Load level set on the inspector
    14.                 Application.LoadLevel (level);
    15.         }
    16.  
    17. }
     

    Attached Files:

    boshko likes this.
  4. boshko

    boshko

    Joined:
    Jan 22, 2015
    Posts:
    20
    Thanx guys:)