- Home /
Coloring the Custom Inspector
Hello people, i have a small question. I am not really good at this custom inspector stuff, I am trying to learn some new tricks all the time. Now, I can create a custom editor, basically like this:
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(IE_WeaponScript)), CanEditMultipleObjects]
public class IE_WeaponScriptEditor : Editor {
public override void OnInspectorGUI()
{
IE_WeaponScript weaponScript = (IE_WeaponScript)target;
serializedObject.Update();
// My fields...
serializedObject.ApplyModifiedProperties();
}
}
I simply want to color the inspector, instead of default light grey, I want to color it to red, or black anything. I searched it up, found this. But could not apply it to my needs, i think that is about CustomWindows. So, is there any little trick that does this or do I have to draw a texture behind all my elements in the custom inspector, if so, how can I draw it properly in order to make it cover all the inspector? Thanks :).
Answer by Bunny83 · May 17, 2015 at 05:33 PM
All background colors in Unity are drawn with textures. Those textures are defined in the GUIStyles you use to draw all your stuff. A custom inspector doesn't have a dedicated background as it simply draws onto the InspectorWindow (which btw is also just an EditorWindow ^^). Using DrawTexture for the background has the disadvantage that it doesn't account for the play-mode-tinting. For that you have to use the GUIStyle background.
See the comments below this answer and also my general purpose Unity OnGUI post over here
Thank you! I had no idea about the matter but now since I understand the logic I believe I can easily handle that.
Your answer
![](https://koobas.hobune.stream/wayback/20220613195831im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Custom color for properties in Inspector. 1 Answer
Custom Inspector Variables 1 Answer
How can I create a list of preset class/objects to be used in the editor 1 Answer
How would I go about creating a custom Unity Event in a Custom Unity Editor/Inspector? 0 Answers
Avoid Base Values being public via Custom Inspector 1 Answer