Question by
StarCmd · Jan 28, 2018 at 10:42 PM ·
editor-scriptingguistyle
How to use a custom GUIStyle inside an EditorWindow
hi, using an EditorWindow, I can't figure out how to define a custom style for my gui elements. Here is a short code illustrating what I am trying to do (and how I mess up) :
Thanks for help
public class myEditor : EditorWindow {
private GUIStyle myFoldOutStyle = new GUIStyle();
public static void Init() {
EditorWindow.GetWindow(typeof(myEditor), false, "myEditor");
}
private void Awake(){
myFoldOutStyle.margin = new RectOffset(20, 20, 20, 20);
}
private void OnGUI()
{
EditorGUILayout.Foldout(true,"Label", myFoldOutStyle);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612151511im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I execute code while dragging an ArcHandle? 0 Answers
Process Terrain and Water in Editor? 0 Answers
why can't we set lighting parameter by script 0 Answers
I really need some help and it's frustrating 1 Answer
UI Text is not being rebuilt/updated in edit mode, when changing text from OnInspectorGUI 1 Answer