Question by
FearMe · Mar 26, 2016 at 06:21 AM ·
unity 5onguiongui error
Why is OnGUI not being called on StandAlone?
So I just have some basic code that runs in my game as seen below to check if OnGUI is being called. It runs fine on the Unity editor, just not on my Mac OSX standalone... Any help?
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using System;
public class Game : MonoBehaviour {
public static List<string> messages = new List<string>(new string[]{""});
// Use this for initialization
void Start () {
}
void OnGUI(){
G.print(Time.time+"");//Just a method that adds this message to the messages list and also Debug.Log()'s it
try{
Gfx.drawText(messages[messages.Count-1], 10, 10, Color.white, 30);//This method simply draws the last message in the top right corner
}catch(Exception e){
G.print(e.Message);//Catches errors
}
}
// Update is called once per frame
void Update () {
}
}
So basically, the text is drawn on the screen fine in editor mode, however does not show up at all in the Mac OSX standalone.
Comment
Best Answer
Answer by FearMe · Mar 26, 2016 at 06:47 AM
So weird thing... I literally just created a new C# script, copied and pasted my code into it, and it worked?... Unity bug maybe?
Your answer
![](https://koobas.hobune.stream/wayback/20220612073332im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
OnGUI behind UI? 0 Answers
Map creator inside my game 0 Answers
Help with Pause Menu 1 Answer
Advice on creating 2d Inventory System with Unity 0 Answers
iron sight using inverse kinematic 0 Answers