Search Unity

Custom Editor gui skin

Discussion in 'Immediate Mode GUI (IMGUI)' started by Wildregar, May 12, 2016.

  1. Wildregar

    Wildregar

    Joined:
    Mar 2, 2014
    Posts:
    20
    Hi,

    I'm creating a custom Editor skin, with Windows and custom inspector. I would like to change the skin of the editor.
    For some element I use the relative GUI function with custom style, but I want to use my custom skin for all my component, without specify it everytime.
    I try to set Gui.skin = myskin , but this change completely the GUI of unity......

    And in this way I cant change the background of GUI.BeginScrollView because this method dont have a GUI.style for the content background like GUILayout.BeginScrollView.

    Another thing I want to do is create the background of my Scrollview like the background of Animation component in unity, with repeated tiles.

    Anyone give me a help? :)
     
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Do you want to do something like this?

    ex:
    Code (csharp):
    1.  
    2. public override void OnInspectorGUI()
    3.     {
    4.         GUISkin origSkin = GUI.skin;
    5.         GUI.skin = EditorGUIUtility.GetBuiltinSkin( _isDarkSkin ? EditorSkin.Scene : EditorSkin.Inspector );
    6.      
    7.         //...
    8.  
    9.         GUI.skin = origSkin;
    10. }
    11.  
    edit:
     
    Last edited: May 12, 2016
  3. Wildregar

    Wildregar

    Joined:
    Mar 2, 2014
    Posts:
    20
    Yes!! Now I can load my custom skyn :)

    Code (CSharp):
    1.  
    2. GUISkin oldSkin = GUI.skin;
    3. GUI.skin = Resources.Load<GUISkin>("Skins/GraphSkin");
    4. ......
    5. GUI.skin = oldSkin;
    6.  
    And what I have to do for get a background of ScrollView like this?
     
  4. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
  5. Wildregar

    Wildregar

    Joined:
    Mar 2, 2014
    Posts:
    20
    I did it in this way and woorks fine! Thanks for the help :)
    Code (CSharp):
    1.  
    2. Rect rectInsideScrollView = Calculation....
    3.  
    4. //Draw Internal Background Repeated
    5. Texture2D repeatedTexture = DrimkyStyle.InsideScrollViewTexture;
    6. for(int x = 0; x < rectInsideScrollView.width; x += repeatedTexture.width){
    7.     for(int y = 0; y < rectInsideScrollView.height; y += repeatedTexture.height){
    8.         GUI.DrawTextureWithTexCoords(new Rect(x, y, repeatedTexture.width, repeatedTexture.height), repeatedTexture, new Rect(0f, 0f, 1f, 1f));
    9.     }
    10. }
    11.  
     
    IzzySoft likes this.