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 createdbyx · Apr 27, 2012 at 08:38 AM · editortexturetexture2d

path to texture problem -> EditorGUIUtility.FindTexture

Another newbie question! I can't seem to load/use a texture for a gui button in my editor script?

I have an Editor folder in my project and under that folder is a script (EditorGUIUtilityFindTexture ) and a texture (Extents) alt text

I am using the script from the unity docs here

No matter what path I use it does not want to return the texture when calling EditorGUIUtility.FindTexture.

I am working on some editor tools and everything is going great until this texture problem. Below is some of my editor code ...

 public class QuickMouseEditingTools : Editor
 {
     Texture2D blackTex;
     Texture2D whiteTex;
        Texture2D Extents;
 
     public void OnEnable()
     {
         if (this.blackTex == null)
         {
             this.blackTex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
             this.blackTex.SetPixel(0, 0, new Color32(0, 0, 0, 255));
             this.blackTex.Apply();
         }
 
         if (this.whiteTex == null)
         {
             this.whiteTex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
             this.whiteTex.SetPixel(0, 0, new Color32(255, 255, 255, 255));
             this.whiteTex.Apply();
         }
  
         this.Extents = EditorGUIUtility.FindTexture("Textures/Extents");
 ... etc

and I'm trying to setup a button in my editor using ...

  if (GUILayout.Button(this.Extents, GUILayout.MinWidth(16), GUILayout.MinHeight(16)))
         { }


What would be the path to pass into EditorGUIUtility.FindTexture for it to return the Extents texture? (Extents texture type is set to Texture btw)

I've tried all sorts of crazy paths like Assets/Editor/Textures/Extents, Editor/Textures/Extents etc even trying to replace forward slashes with backslashes etc. Nothing seems to work.

UnityTextures.png (32.6 kB)
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
1

Answer by Camen · Apr 28, 2014 at 08:20 PM

Tried to do the same thing today and ran across your question.

As far as I can tell, the EditorGUIUtility.FindTexture function doesn't actually do anything. Here's a similar question and a workaround you can use.

Basically you can get a texture by using the EditorGUIUtility.Load function. The caveat is that this can only load stuff from a folder called "Editor Default Assets." The official documentation explains it pretty well.

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

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

Editor class "Texture Importer" question (applying settings to multiple texture assets). 2 Answers

Same BackGroung For All Screen Resolution 1 Answer

How to get ARGB values from Texture object? 1 Answer

2DTexture "lines" despite clamp & no mip-mapping 0 Answers

Importing FBX with textures 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