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
1
Question by UnityBrains · Dec 15, 2011 at 07:44 AM · editorguiskincustomeditor

GUISkin and CustomEditor

Hey there,

Is there something special I have to do to get a GUISkin working in a custom editor? I currently have the code:

 using UnityEditor;
 using UnityEngine;
 using System.Collections;
 
 [CustomEditor(typeof(TexturedObjectCS))]
 public class TexturedObjectEditorCS : Editor
 {
     public override void OnInspectorGUI()
     {        
         GUI.skin = new EditorSkin();

...but it's not working. It's giving me an error about converting EditorSkin to GUISkin. All of the documentation, however, indicates that this should work. I created a skin by going Assets > Create > GUI Skin and named it EditorSkin.

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

1 Reply

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

Answer by UnityBrains · Dec 15, 2011 at 07:54 AM

Okay, I got it sorted. You have to load the GUISkin resource for some reason. I might look into the details later.

Instead of

 GUI.skin = new EditorSkin();

I had to use

 GUI.skin = (GUISkin)(Resources.LoadAssetAtPath("Assets/EditorSkin.guiskin", typeof(GUISkin)));

Awesome.

Comment
Add comment · Show 1 · 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 oriolmanya · Nov 03, 2017 at 07:11 AM 1
Share

Thanks for the answer. Two considerations: 1.In Unity 5 - 2017 it changed to UnityEditor.AssetDatabase.LoadAssetAtPath 2.I guess It would be better to load this line OnEnable, save it as a local variable an use it on the iterations. Ex:

             private GUISkin mySkin;
             void OnEnable()
         {
             mySkin = (GUISkin)(UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/$$anonymous$$yCoolSkin.guiskin", typeof(GUISkin)));
         }
 
 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Can custom editors that are built using Reflection.Emit be used in the Unity Editor? 1 Answer

Change variable in inspector depending on enum using struct 0 Answers

Problem with ScriptableObject and Custom Editor 2 Answers

Editor Targets are updated but SerializedPropertys arent 1 Answer

Can you have custom EditorGUILayout fields? 0 Answers


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