- Home /
GUILayout Button as custom button from custom script
Hello I'm working on GUI and get stuck a bit, could you help me please?
I'm defining box area as flexible space and list few elements
GUI.skin = MyCustomSkin;
GUILayout.BeginArea(new Rect(<some_params>));
GUILayout.FlexibleSpace();
pass = GUILayout.PasswordField(pass, '*', new GUILayoutOption[] { GUILayout.Width(inputFiledLength), GUILayout.Height(inputFiledHight) });
loginName = GUILayout.TextField(loginName, new GUILayoutOption[]{GUILayout.Width(inputFiledLength), GUILayout.Height(inputFiledHight)});
if (GUILayout.Button("Login", new GUILayoutOption[] { GUILayout.Width(inputFiledLength / 2 - 1), GUILayout.Height(inputFiledHight) }))
{
if (!loginName.Equals("Login Name") && loginName.Length >= 6 && !pass.Equals("Password") && pass.Length >= 6)
{
md5hash = GetMD5(loginName + pass);
setState(ClientState.loginProcess);
}
}
GUILayout.FlexibleSpace();
GUILayout.EndArea();
The problem is that my "Loggin" button uses original button from MyCustomSkin
However I did define custom button with other textures
How would I change now my button statement:
if (GUILayout.Button("Login", new GUILayoutOption[] {
GUILayout.Width(inputFiledLength / 2 - 1),
GUILayout.Height(inputFiledHight) })) { ***
to use my custom style button - "button1" and add text "Login" on top of it
Thank you very much!
Answer by Jamora · Jul 20, 2013 at 09:32 PM
In the API for GUILayout.Button, it says the style is passed as the second parameter, before GUILayoutOptions. So try GUILayout.Button("Login", "button1", new GUILayoutOption[] { GUILayout.Width(inputFiledLength / 2 - 1), GUILayout.Height(inputFiledHight) })
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Custom GUIStyle Border 1 Answer
Multiple Cars not working 1 Answer
AddListener to OnPointerDown of Button instead of onClick 4 Answers
Problem with onClick.AddListener 1 Answer