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 Delamore81 · Nov 03, 2013 at 01:35 PM · buildtexture2dbuttonsdisappearmouse-over

Why is GUI texture not showing on mouse over in build?

I have buttons in my main menu which would change texture upon mouse over. The changing of the textures on mouse over works fine in the editor. But after build, the textures do not show at all when the button is moused over. It is simple a blank button. I know the button is still there because I am able to click on it and it will execute a function.

This is how I have done it in code.


void Start() { PathStartBtn1 = "Assets/Textures/Buttons/Start_Default.png"; PathStartBtn2 = "Assets/Textures/Buttons/Start_MouseOver.png"; Tex2D_StartBtn1 = (Texture2D)Resources.LoadAssetAtPath(PathStartBtn1, typeof(Texture2D)); Tex2D_StartBtn2 = (Texture2D)Resources.LoadAssetAtPath(PathStartBtn2, typeof(Texture2D)); }

void OnMouseEnter() { gameObject.guiTexture.texture = Tex2D_StartBtn2 ; }

void OnMouseExit() { gameObject.guiTexture.texture = Tex2D_StartBtn1 ; }


The funny thing is the original texture for the button does show up when the game starts. Only when the cursor goes over it, it simply disappears.

Please help... Anyone?

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 Delamore81 · Nov 09, 2013 at 08:48 AM

Okay, So I finally figured it out. These are the things you should be aware of when using GUItexture and accessing assets from folders.

  1. DO NOT USE Resource.LoadAssetAtPath() . It may work on some build but I realized that it is an Editor-Only function, which means it will always work in the editor but it MAY NOT WORK in the build itself.

  2. Use Resource.Load("SomeAsset") instead.

  3. The folder in which you can access your assets MUST be in a folder named "Resources". You could also put sub-folders into this folder. Simple use the forward slash in your path. For example, "Buttons/SomeAsset".

  4. And lastly, which is the most crucial of course... DO NOT leave the extension in your path. For my case, I would use Resource.Load("Buttons/Start_Selected"), instead of "Buttons/Start_Selected.png". This is the main culprit of why the Load function returned a Null in the build.

Hope this will helped somebody. Cheers!

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 Ensutee · Nov 22, 2013 at 02:55 AM 0
Share

THAN$$anonymous$$ YOU!! this was giving me a $$anonymous$$AJOR headache

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

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

My OnGUI() Won't show the Button elements :( 0 Answers

Screen.width & Screen.height Becoming button 0 Answers

SetCursor WebGL doesn't work 1 Answer

What are possible causes and solutions to randomly garbled textures on standalone builds? 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