Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Uzquiano · Mar 19, 2011 at 03:15 PM · javascriptassignguiskin

Assign myGUISkin in javascript

Hi,

I want to assign my own GUISkin to the GUI.skin in javascript. Till now I have written this code (shown bellow) but I don't know how to assign myGUISkin = the GUI skin I created in the inspector.

So, the whole context is like this: the GUISkin I created is called "EsGUIskin.guiskin" and I have it in my project folder.

And in a script I have written:

var myGUISkin : GUISkin;

BUT HOW do I SAY THAT myGUISkin=EsGUIskin.guiskin?????

function OnGUI () {

 GUI.skin=myGUISkin;

//whatever here }

Thanks in advance,

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Uzquiano · Mar 19, 2011 at 06:39 PM

So after many tries, I thought (with my head) and the solution is as simple as this, code shown below:

var myGUISkin : GUISkin;

function Start () { myGUISkin = Resources.Load("EsGUIskin"); }

function OnGUI () {

 GUI.skin = myGUISkin;

 GUI.Box (Rect (10, 10, 100, 20), "Espaol o");
 GUILayout.Box ("Espaol o");
 }

Cheers

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Eric5h5 · Mar 19, 2011 at 05:28 PM

Just drag the skin onto the slot in the inspector.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Uzquiano · Mar 19, 2011 at 05:52 PM 0
Share

Please, I want to do it in my SCRIPT (javascript). I already know the drag-and-drop solution... If it is not possible just say to me please.

avatar image Eric5h5 · Mar 19, 2011 at 06:05 PM 0
Share

It wasn't clear that you knew about drag-and-drop. You can use Resources.Load, but I'd recommend using drag-and-drop unless you have good reason not to.

avatar image Uzquiano · Mar 19, 2011 at 11:12 PM 0
Share

Thanks anyway Eric5h5, for helping me and others. I am improving quite fast in Unity scripting thanks to your and others help.

And yes, I do have reasons for using javascript as much as possible ;)

avatar image
0

Answer by lcn75 · Dec 20, 2011 at 07:45 AM

Hi, try this...(the name of my skin is 'My Skin' in the 'Assets/SKIN' folder).

 var myCustomSkin : GUISkin;
 
 function Start () {
 myCustomSkin = Resources.LoadAssetAtPath("Assets/SKIN/MySkin.GUISkin", GUISkin);
 }
 
 function OnGUI () {
   GUI.skin = myCustomSkin;
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lcn75 · Dec 20, 2011 at 07:46 AM 0
Share

When you play the game it works!

avatar image Shlizer · Jul 16, 2012 at 08:11 PM 0
Share

In documentation there is: "Returns a resource at an asset path (Editor Only).", so after building standalone version it can couse problems. It's better to use 'Resources.Load' ins$$anonymous$$d.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Assign material and guiskin to variables 1 Answer

Adding GUI Skin to a script in the project library 1 Answer

Unable to find style 'HUD Button' in skin 1 Answer

JavaScript OnGUI GuiSkins aren't working, multiple scripts 1 Answer

Cannot Assign Material To Object 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges