- Home /
 
My Custom Style changes everything in the Editor, why?
Hi there,
i have one Big Problem...
I made a Customn Style for my Custom Editor Window and it works....but it changes also the Editor built in Stuff...
In my Window i want a Big Label as a Toolbar, because a Toolbar looks great, i set the Fix height to 50 and it works.... but THEN, it change all Toolbars in the Editor to 50. I have no Idea why. Because i used a Custom Style...
Heres comes the code:
 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 
 public class SHS_SpawnSystemWindow : EditorWindow {
 
     GUIStyle logoSHS = new GUIStyle ();
     public Texture2D logo;
 
     [MenuItem ("SHS/Shit SpawnSystem")]
     public static void ShowWindow ()
     {
 
         EditorWindow.GetWindow (typeof (SHS_SpawnSystemWindow), false);
 
 
        
     }
 
     void Awake ()
     {
 
         logo = Resources.Load ("logo_shs") as Texture2D;
 
     }
 
     void OnGUI ()
     {
 
         logoSHS.fontSize = 50;
         logoSHS.fontStyle = FontStyle.Bold;
         logoSHS.normal.textColor = Color.white;
         logoSHS = EditorStyles.miniButton;
         //logoSHS.fixedHeight = 80;
         logoSHS.padding = new RectOffset (0, 0, 0, 0);
         logoSHS.margin = new RectOffset (0, 0, 0, 0);
 
         GUI.backgroundColor = Color.black;
         EditorGUILayout.BeginVertical (logoSHS,GUILayout.Height (125));
         GUILayout.FlexibleSpace ();
         GUI.backgroundColor = Color.grey;
         EditorGUILayout.BeginHorizontal ();
 
 
         GUILayout.Label ("Shit SpawnSystem", logoSHS, GUILayout.Height (100));
 
 
 
         GUILayout.Label (logo, logoSHS, GUILayout.Height (100), GUILayout.Width (100));
 
 
         EditorGUILayout.EndHorizontal ();
 
         GUILayout.FlexibleSpace ();
         EditorGUILayout.EndVertical ();
         
         
     }
     void OnDestroy () //this was a test, but also doesn't work
     {
         logoSHS=null;
         Debug.Log ("geschlossen");
     }
 }
 
 
               well as it is said in the doc if you assign fixedHeight , any GUI elements rendered with this style will have the height you specified.
I don't see where it changes Built-in stuff...
Here...that is what i mean! Changing everthing... also the Font Size_/Color..... and so on! and THIS.. is not normal! I create a custom style and don't edit the default one!
No ;) but i want to sell it later on the Asset Store... (maybe 15$) The System works but this GUI Design Elements are going Crazy.
Answer by Ogdy · Aug 13, 2018 at 11:39 AM
Probably way too late, but here is the anwser for others :
logoSHS = EditorStyles.miniButton;
logoSHS.padding = new RectOffset (0, 0, 0, 0);
logoSHS.margin = new RectOffset (0, 0, 0, 0);
Here you are giving logoSHS the same reference as EditorStyles.miniButton, so when you do :
logoSHS.padding = new RectOffset (0, 0, 0, 0)
you are in fact also doing :
EditorStyles.miniButton.padding = new RectOffset (0, 0, 0, 0)
and EditorStyles is used everywhere, so it changes everywhere :)
What you can do is simply make a copy, like this :
logoSHS = new GUIStyle(EditorStyles.miniButton)
Your answer
 
             Follow this Question
Related Questions
Cloud recognition in Vuforia 0 Answers
Can I use Pro features? 1 Answer
on start a new game texture is not appearing 0 Answers
Move Object by dragging (mobile) makes the balls fall from the cup 1 Answer
How can I Pool array of objects? 3 Answers