- Home /
Variable from String
Hello :D
I have a script in Unity and there is a small thing I need help with. I have a variable called v0 and it is a GUIStyle variable. I also have a string called digit that equals "0". The GUI.Button takes a GUIStyle variable at the end. I could just put v0, but is there a way to call this variable using a string.
Something like: GUI.Button(new Rect(0, 0,sizeX , sizeY),"", ("v" + digit[0]));
The problem is how do I make ("v" + digit[0])
refer to the v0 variable?
Thanks for the help :) Muhasaresa
Hi,
It would help to clarify why exactly you want to do this, because it seems like you want to use a string as the 3rd parameter of the GUI.Button function, and of course you can't do that.
$$anonymous$$aybe what you want to accomplish can be done using the custom elements of the GUIStyle... but it's not at all clear why you want to do something like this.
Also, what do you mean "call this variable using a string"... I mean, you can USE a variable e.g. as part of an operation or as a parameter in a function. So, what do you mean "call it"?
Your answer
Follow this Question
Related Questions
GetComponent with variable script possible? 1 Answer
How to get a value and keep it updated 2 Answers
Using a String in an Enable statement 2 Answers
GUI text label using variable values and text 1 Answer
transform.name value to a variable 2 Answers