Hi there,
I’ve encountered a problem with the custom styled Active state of GUI.button .
There is a singelton custom GUImanager that calls a drawGUI() method of some custom GUI classes that are stored in a list.
In the custom GUI element RyGUIbutton (not related to Unities GUIelement)
public override void drawGUI()
{
if (GUI.Button(m_displayBox, m_locaText, RyGUImanager.instance.m_Skin.customStyles[m_customStyleIndex]))
{
if (ButtonClicked != null)
{
ButtonClicked( e );
}
}
}
And the GUImanager calls those methods in OnGUI() for all custom GUI classes:
private void drawGUIelements()
{
GUI.skin = m_Skin;
foreach (RyGUIelement ryGUIelement in m_ryGUIelements)
{
ryGUIelement.drawGUI();
}
}
All is displayed fine - the Buttons even have their Hover state (from the custom style) and the click event is fired (ButtonClicked is a custom event). But when the button is pressed the normal state comes up again and the Active state is ignored.
If I put the same code in an OnGUI() method - the active state is working properly.
Now you might ask: why not simply use the OnGUI() ?
Well, I really would like to do this without separate calls -
The Render order of the GUI objects is set through custom code where GUI.depth wouldn’t work.
And I found out that using lots of OnGUI() calls slow down the frame rate drastically.
( funny part is - even if OnGUI() is empty ooOO )
I guess that’s because of some overhead produced by sorting order etc… but thats speculation.
Has anyone come over this before?
The only difference is that the button is called externally - but that shouldn’t matter.
And why the hack is Hover working but the active state is not?
(OnActive isn’t working either)
Btw. this is my first Post (ooOO)- but this is eating up my nerves for 3 Days now -
Am I missing out something obvious?
Ah - The RyGUIbutton inherits from RyGUIelement which inherits from MonoBehaviour - all programmed in C#
There are no other events used - especially no Event.current.type or similar…
I would appreciate any suggestion.
This is really getting on to me …