Hi,
Attempting to get a UI Panel to match the color and background of a GUI Window. Currently, using the default style for a GUI Window. Attached is a screenshot of the GUI Window. I’ve tried access the GUI Skin but to no avail. I’m wondering if there’s a way to access IMGUI via the Inspector?
Help is appreciated.
No and please don’t use IMGUI to begin with. It’s completely surpassed by both UGUI (game object based) and UI Toolkit. For the UI shown here, I could make that layout and have the callbacks of the buttons and checkbox established in 10 minutes with UI Toolkit / UI Builder. And that’s fully skinnable too, it even supports themes ie complete overhauls of the styling that you can just swap out and have a xmas theme.
Hi,
Thx for the reply. It’s appreciated. However, we’re just trying to get a UI Panel to match the color scheme of the gui window. That is, the black border and color with the clear or transparent background.
You can do this with materials in the standard Canvas UI with effectively zero effort. There’s almost no reason to use IMGUI anymore unless you’re making editor tools and even there it’s been superseded by UTK.
Hi,
Thanks for the reply. We currently have the Panel in a Canvas. Just trying to find out how to get the color scheme from the GUI Window, so it can be applied to the UI Panel. So, was wondering if a image from the IMGUI is being used to give the GUI Window its look? Here’s some sample code:
var panel = canvas.transform.Find("pnlObj");
Image img = pnlHud.GetComponent<Image>();
// now, get the backgrouund image of a GUI Window
GUIStyle style = new GUIStyle("window");
Texture2D texture2D = style.normal.background;
Sprite sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), Vector2.zero);
img.sprite = sprite;