Search Unity

My game crashes when I use GUI in scripts...

Discussion in 'Android' started by aixaix, Sep 21, 2014.

  1. aixaix

    aixaix

    Joined:
    May 7, 2010
    Posts:
    523
    The title pretty much explains itself, but here's all the code i have right now...
    (When It loads the scene, the game just restarts itself...)
    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class Mechanics : MonoBehaviour {
    6.    public int bloodDrops = 0;
    7.    public int teeth = 0;
    8.    public int money = 100;
    9.  
    10.    public GUISkin skin;
    11.  
    12.    public void Awake() {
    13.      LoadData();
    14.    }
    15.  
    16.    public void SaveData() {
    17.    
    18.    }
    19.  
    20.    public void LoadData() {
    21.    
    22.    }
    23.  
    24.    public void OnGUI() {
    25.      GUI.skin = skin;
    26.      GUI.Box(new Rect (0, 0, Screen.width, Screen.height), "", "GameBox");
    27.      GUI.Box(new Rect(Screen.width / 2 - Screen.width / 4, 0, Screen.width / 2, Screen.height / 8), "", "HeaderBox");
    28.    }
    29. }
    30.  
    31.  
     
  2. Dzxyan

    Dzxyan

    Joined:
    Sep 23, 2013
    Posts:
    167
    You just one scene? or loadlevel from other scene?