Search Unity

GUISkin in C#

Discussion in 'Immediate Mode GUI (IMGUI)' started by teleios, Aug 13, 2008.

  1. teleios

    teleios

    Joined:
    Mar 6, 2008
    Posts:
    11
  2. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public class MyTest : MonoBehavour
    4. {
    5.     public GUISkin _theSkin = null;
    6.  
    7.     void OnGUI()
    8.     {
    9.         if (_theSkin != null)
    10.         {
    11.             GUI.skin = _theSkin;
    12.         }
    13.     }
    14. }
    Hope that helps,
    -Jeremy
     
  3. teleios

    teleios

    Joined:
    Mar 6, 2008
    Posts:
    11
    Yes, that's perfect thank you.

    I do have one more question, however.

    I used your example and I was able to add the skin in the inspector, but none of the custom changes I made altered the GUI elements. For example, in the GUISkin (called _mySkin). I changed every possible value of text color in the skin for a button yet, nothing changed the default styles on the button.

    Is there anything specific you have to do to make the changes take affect? From my understanding there wasn't anything so I'm a bit confused.

    Again, I appreciate any help and thanks in advance. This community is amazing. :)
     
  4. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    Are you setting the skin in the same OnGUI function as your GUI code is?
     
  5. teleios

    teleios

    Joined:
    Mar 6, 2008
    Posts:
    11
    Yes. That was one of the first things I made sure of. I also tried applying the skin to different scenes and different OnGUI functions while I was trying to debug it.
     
  6. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728