x


Is GUISkin only a Pro ability?

I've been searching the forums and faqs and tried all the samples. GUISkin doesn't work. I tried creating a guiskin (twice!), dropping it on an empty or the camera (but it won't let me edit it in the inspector for those objects but seems to list it, but won't let me select one (shows Assets as empty when you click to bring up Assets within inspector for a change).

And I tried GUI.skin = myguiskin in a script that is assigned to both an empty and a camera (just to confirm). The controls are created but the skin is never applied.

I tried that both in C# and javascript, and even tried the sample codes exactly as shown. The guiskin is ignored.

I also tried doing a custom style and yes, that works per assigned control(but unfortunately wipes out the borders, etc. that you get with the default, so isn't pretty, and doesn't seem an easy solution unless you are doing to do a lot of very customized, non-scalable GUI controls.)

[the above with custom styles might be expected behavior, I don't know, since the example tutorials in the docs don't seem to show much in the way of textures (usually just text without any background). and I don't know what to expect for guiskin since it won't come up at all.]

So it makes me wonder if it's only available if you have Pro?

I have latest free edition of Unity and haven't reached the point of needing Pro yet.

Thanks so much for any insight (and again, I've tried all the samples and read all the docs, and searched the forums, but nothing works and no one clearly states if this is Pro only ability)...

Thanks, Cynthia

more ▼

asked Jul 20, 2013 at 12:09 AM

CGinSeattle gravatar image

CGinSeattle
3 3 2 2

Can you post some more context other than just on an empty and on a camera? I think you are using it incorrectly.

Jul 20, 2013 at 12:28 AM Deathcalibur

certainly, but as I said, I used code directly from samples and it still didn't work. the buttons etc create, even a style works, but not the skin. and each time, I created a skin the usual way and then changed the texture to use or the text color, etc. and named it to match the GUISkin referenced in the script. thanks

First tried this: attached to an empty, and then to the camera. public class GUITest : MonoBehaviour {

public Texture btnTexture;
public GUISkin myGUISkin;
public GUIStyle customButton;



public Rect windowRect = new Rect(20, 20, 250, 250);
public bool showWinID0 = false;  
public static int guiDepth = 0;
void OnGUI() {
    GUI.depth = guiDepth;
    GUI.skin = null;
    if (!btnTexture) {
        Debug.LogError("Please assign a texture on the inspector");
        return;
    }
    if (GUI.Button(new Rect(10, 10, 50, 50), btnTexture))
    {
        Debug.Log("Clicked the button with an image");
        GameObject go = GameObject.Find("Tree");
        go.GetComponent<Spin>().start = false;
        go.GetComponent<Spin>().speed += 10f;
    }
    GUI.skin = myGUISkin;


    if (GUI.Button (new Rect (10,10,150,20), "I am a Custom Button", customButton))
    {
        Debug.Log ("custom button");
    }

    if (GUI.Button(new Rect(10, 70, 150, 30), "Click-MakeWindow"))
    {
        Debug.Log("Clicked the button with text");
        showWinID0 = true;
    }
    // Register the window.
    if (showWinID0)
    {
        //GUI.skin = myGUISkin;
        windowRect = GUI.Window (0, windowRect, DoMyWindow, "My Window", customButton); //0 is the window id of this popup window
    }

}
void HideWindow()
{
    showWinID0 = false;
}
void DoMyWindow(int windowID) {
    int guiDepth = 0;
    //GUI.depth = guiDepth;
    //GUI.skin = myGUISkin;

    if (GUI.Button (new Rect (10,20,100,20), "Close the Window"))
    {
        guiDepth = 0; //top....not working in either guiDepth attempt, for buttons with different depth need two scripts
        //but what about a window that is created and its children? can I change teh child order??
        Debug.Log ("Got a click");
        HideWindow ();
    }
    GUI.DragWindow(new Rect(0, 0, 10000, 2000)); //put last, apparently it covers up the other buttons! and those can't get clicked despite appearing to be!

}

}

then tried just a quick javascript, attached again to first an empty, then the camera

var mySkin : GUISkin;

function OnGUI () { // Assign the skin to be the one currently used. GUI.skin = mySkin;

// Make a button. This will get the default "button" style from the skin assigned to mySkin.
GUI.Button (Rect (10,10,150,20), "Skinned Button");

}

Jul 20, 2013 at 01:00 AM CGinSeattle

Not sure. The only thing I can say is to make sure you are setting the "Button" style and not another style, and also to make sure you are changing the Normal behavior, not On Normal or whatever.

Jul 20, 2013 at 01:07 AM Deathcalibur

I am changing Normal (not On Normal) and I don't even try to change the style to 'button'....what you see is exactly what is there.

the first is a lot of code that I was trying variations, but the javascript is just creating the standard button...it's the exact code the docs say to use...the button is created but no skin (i.e. the GUI.skin = mySkin) is applied.

thanks anyway

Jul 20, 2013 at 01:14 AM CGinSeattle
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Where it says "None (GUISkin)" you can click the circle at the end of the line and assign the skin in the inspector that way. Sounds like that is your issue. You can also drag it onto the text "None (GUISkin)" and it will highlight the area with a blue before you drop it.

Alternately you can do the following:

private GUISkin myGUISkin;

void Start () {
    myGUISkin = Resources.Load("MyGUISkin") as GUISkin;
}

You need to create a folder in your assets folder named "Resources", and then put the GUISkin you created in there. Also, change the "MyGUISkin" to match the name of the GUISkin file you created.

more ▼

answered Jul 20, 2013 at 01:13 AM

Deathcalibur gravatar image

Deathcalibur
158 14 14 17

I wondered about that, but when I click on the circle and get the window that should have my selectable GUI skins in Assets (or even Scene), there is nothing there! I tried creating another skin, but again, nothing shows up.

But I will try and do the drag idea, since I haven't tried that one yet.

I wonder if this is another issue with running Unity on 64 bit windows systems...

thanks

Jul 20, 2013 at 01:18 AM CGinSeattle

I edited my comment to show you how to do it with code instead of utilizing the drag & drop features in case this is more clear for you.

I run Unity on Windows 64-bit and have no issues.

Jul 20, 2013 at 01:19 AM Deathcalibur

the drag worked, but again thank you for the code (always appreciate a programmatic way to do things!)

thank you!

Jul 20, 2013 at 01:27 AM CGinSeattle

but man, that custom way isn't that great (at least at first try)..you lose the rounded corners, the borders, everything... I wish they'd allow for keeping the borders/rounding etc. and just let you customize the background, colors, etc. without other losses.

hopefully, I'm just missing something easy again. :)

Jul 20, 2013 at 01:32 AM CGinSeattle

If you just want to tweak an existing skin instead of making a new one, then it's easiest to create GUIStyles in code and change only the elements you're interested in.

Jul 20, 2013 at 01:41 AM Eric5h5
(comments are locked)
10|3000 characters needed characters left

If it was Pro-only, the docs would say so.

var mySkin : GUISkin;  // <- drag GUISkin here in the inspector

OnGUI () {
    GUI.skin = mySkin;
}
more ▼

answered Jul 20, 2013 at 01:00 AM

Eric5h5 gravatar image

Eric5h5
107k 52 180 648

thanks for the response, but as I said, I tried that already and it did not work.

and sometimes the docs are unclear.

one thing I noticed in your comments: what do you mean 'drag GUISkin here in the inspector', as I said, I tried dragging my custom skin from Assets tab onto a object in the Hierarchy window, then looking at that object in inspector, I do not see the guiskin by itself anywhere...if I drag the script onto the objec,t I do see the script, but I cannot touch the skin in anyway...it says (for example) My GUISkin and then None (GUISkin).

As for just the skin by itself, if I select the guiskin in the Assets tab, then click Inspector, I see the elements in the Inspector, but I can't 'drag' it anywhere.

Jul 20, 2013 at 01:10 AM CGinSeattle
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x216
x92
x4
x4

asked: Jul 20, 2013 at 12:09 AM

Seen: 693 times

Last Updated: Jul 20, 2013 at 01:46 AM