Here’s the idea, I want a checkbox - I know it already exist - that support a third states - that doesn’t exist.
So, I thought of creating a new checkbox method by drawing textures depending of the different state… But that doesn’t make it “a control” that can be focused on, just a texture with a collection of mouse event. Worse, the texture doesn’t appear to be redrawn on MouseDrag. Would that be something flagged by a proper control?
Or imagine I would like to make a new Button, one that would have the following states;
Idle
Hovered
Pressed
Pressed but with the mouse away
Clicked
Focused
For that, I would probably want to handle the mouse event myself as the GUI.Button is sealed to any change.
What is going on behind the scene in that GUI.Button?? How to make a real control visible to GUI?
So far as I know, GUI isn’t object based at all. Button is just a static method that returns a bool stating whether it’s being clicked or not. The manual entry on GUI extensions would seem to point to a similar pattern. You make a method (static or not) that takes a Rect and whatever else you need. My guess is the best you could do is some hacky style swapping to support states not included out of the box.
All the example they do in their tutorial is to compound existing “control”, they never create a new one from scratch. I would like to see the code behind “Button” or “Toggle”. Does anybody decompiled that?
I checked UnityEngine.dll with a .NET Reflector, and sadly, everything that would define a Control appear to be native.
So, creating a control from scratch that uses the same interactions as native Control is just impossible.
Even a button’s behaviour is an internal call.