Aligning EditorWindow controls horizontally/vertically when displaying a Texture2D with GUILayout.Label()
Hey,
so I'm currently working on an In-Editor Item Manager and got stuck on this problem. First, this is an image of how it looks: Bigger icon:
What I need is that the Texture2D (the carrot in the picture) is horizontally aligned with the Color field and it should be independent of the texture size. If the size was always the same, I could just play around with GUILayout.Space(). I guess I could also play around with the texture.height and get the Space() value based off of that, but I feel like it isn't the best way to do it.
Is there a good way to do this? This is the code for the relevant Texture+Colorfield. The flexiblespace isn't doing anything right now, it's as if it wasn't there.
EditorGUILayout.BeginHorizontal();
GUILayout.Label("", GUILayout.MaxWidth(50));
GUILayout.Label(i.ItemSprite);
EditorGUILayout.BeginVertical();
GUILayout.FlexibleSpace();
EditorGUILayout.ColorField(Color.red);
GUILayout.FlexibleSpace();
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
Your answer
![](https://koobas.hobune.stream/wayback/20220612055031im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
code-generated texture compression creates gray texture 1 Answer
WWW.LoadImageIntoTexture works on Android but fails on UWP with Log: "Cannot load image" 1 Answer
procedural Texture antialiasing issue 0 Answers
Better way to edit RawImage texture data?,Better way to edit a RawImage texture? 0 Answers
How to get rect a window of editor? 0 Answers