- Home /
How to add GUIStyle to GUILayout Button
How do I add a GUIStyle to a GUILayout Button? Here is the code I have so far:
GUILayout.Button(Resources.Load(img), GUILayout.Width(sixthOfScreenW), GUILayout.Height(sixthOfScreenH),style);
I am getting an error that says:
No appropriate version of 'UnityEngine.GUILayout.Button' for the argument list '(UnityEngine.Object, UnityEngine.GUILayoutOption, UnityEngine.GUILayoutOption, UnityEngine.GUIStyle)' was found.
Please help!!
Answer by zharik86 · Mar 22, 2014 at 06:53 PM
The options GUILayout.Width(sixthOfScreenW), GUILayout.Height(sixthOfScreenH) must be as array. See, docs. I precisely don't know, but I can assume that it is necessary to do so(write on CSharp):
GUILayout.Button(Resources.Load(img), new GUILayoutOption[] {GUILayout.Width(sixthOfScreenW), GUILayout.Height(sixthOfScreenH)},style);
But if you want to use the button with the fixed sizes, it is simpler to use GUI.Button().
Your answer
Follow this Question
Related Questions
Can you use GUIStyle with GUILayout? 0 Answers
GUILayout.Button image 0 Answers
How can i change the color of GUILayout elements? such as buttons 1 Answer
changing the default position of buttons 2 Answers