- Home /
How to display a string without ToString
Hi everyone, I've been trying to display a string without using the ToString Method. But I keep getting this error GUILayout.Button has invaild arguments.
public string Text;
void OnGUI(){
GUILayout.Button(Text); // error GUILayout.Button has invaild arguments
}
I don't have this problem. $$anonymous$$aybe the following will help us track this down:
1) What version of Unity are you running?
2) What is the exact error message? Do you see it when you build in $$anonymous$$ono, as well as when you try to run using the Unity player?
3) Can you paste the entire C# file for us, with usings and class definition?
Ok now it's working fine with no errors. A moment ago it was giving me an invaild argument error. Has anyone else had this issue? I'm using Unity's current version 3.5.5.
using UnityEngine;
using System.Collections;
public class TextError : $$anonymous$$onoBehaviour {
public string Text;
void OnGUI(){ GUILayout.Button(Text); // error GUILayout.Button has invaild arguments }
I have noticed that I get Intellisense and compiler errors after switching between c# and javascript files in $$anonymous$$onoDevelop, the only fix I've found is simply restarting it.
Answer by Eric5h5 · Sep 25, 2012 at 12:47 AM
That code is fine and compiles and works with no errors.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081443im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
unity c# RPC 0 Answers
Null Reference Exception on instantiated object's script. 2 Answers
adding animation dynamically by script 0 Answers