Hello Unity Community!
I’m trying to implement an “IconButton” that will accept the Id of one of the BuiltIn icons in Unity and will show the icon in the button instead of plain text. For that, my IconButton inherits from UIElement.Button, and I add a UxmlStringAttributeDescription in its UXMLTraits for the user to set the icon Id he wants to the button.
I found the EditorGUIUtility.IconContent to retrieve the icon from the Id set by the user. So I get a GUIContent object, but I do not know how to put this icon inside the button. I need to do this from the code of the IconButton itself, and not like we do for game UI i.e. GUI.Button(new Rect(0, 30, 100, 20), new GUIContent(“Click Me”));
How do I do it? Or is there another way to accomplish this that I don’t know about?
Thanks!