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 thunderseethe · Nov 30, 2014 at 01:01 PM · textureguitexturedisappear

GUI Textures disappearing (on buttons)

I am currently developing an app for Android, and some buttons are losing their textures. The function of the button still works despite the fact that the textures don't exist (the size of the button is the same, but is invisible). I've browsed for roughly an hour with no results.

The code is generally copy-paste, and I'm using game objects as a base for my button texture.

On the button that works:

 #pragma strict
 
 var createText : Texture2D;
 var buty : float;
 
 function OnGUI()
 {
     var screenx = Screen.width;
     var screenh = Screen.height;
     var studybutton = GUI.Button(new Rect(screenx/4, screenh*buty, createText.width, createText.height), createText);
     if(studybutton)
     {
         Application.LoadLevel("CN");
     }
 }

On the button that's failing:

 #pragma strict
 
 var mainText : Texture;
 var buty : float;
 
 function OnGUI()
 {
     var screenx = Screen.width;
     var screenh = Screen.height;
     var studybutton = GUI.Button(new Rect(screenx/4, screenh*buty, mainText.width, mainText.height), mainText);
     if(studybutton)
     {
         Application.LoadLevel("MainMenu");
     }
 }

I've got no clue what exactly is breaking it. On the scene before, this method worked flawlessly, granted it was with one less button (4 total on the scene that breaks, 3 on the one that works fine).

Little more detail: I've noticed that when I first add the objects in, attach the script, then attach the texture, that all the textures work when loading that scene first. If I were to go back to the main menu then navigate back to that scene, the two buttons become (with their functionality and size still working). After maybe starting and stopping the scene 5+ times, the buttons become invisible when starting on that scene, contrary to the prior experience where it exists if that scene is loaded first. Weird.


This error also exists when testing on an Android phone.

-Edit-

I have just reopened Unity to see if the problem still exists (as if turning something off and on would fix an issue like this) and sure enough. pic

Don't mind how the button looks- the resolution is just horribly off for the resolution size available on my screen. It will work fine when tested on the android device (proper set resolution). Same scripts, 4 separate button scripts, 4 separate button textures. Only two button textures show, but all 4 buttons work (if I click where they should be, they do what they should do).

-edit2-

I suppose I should mention that in the screenshot provided, the two missing buttons are located between the two visible buttons, and then one below the lowest visible button. They do overlap, so I've been thinking it's a rendering problem and I might have to take an entirely different approach to this button?

-edit3-

I managed to fix it. The solution: I three game objects, aside from one of the working game objects, then put all of the stuff in there. It's stuff like this that makes me feel stupid. I thought I tried everything but I missed one of the most logical things to attempt. I suppose this also would have worked if I put everything in the camera as well. But this leaves the question: Why did this all happen in the first place?

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
0

Answer by M-G-Production · Dec 01, 2014 at 03:59 AM

Hey thunderseethe!

I might be totally wrong, but I saw that the first script got a Texture2D variable and the other is a Texture var... Wich are not the same. Try changing Texture for Texture2D in the second script.

Math

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Guitexture appear/disappear 1 Answer

Texture's Alpha is not Transparent when I use it as a GUI.label 1 Answer

Assigning UV Map to model at runtime 0 Answers

Joysticks disappears Android 1 Answer

GUI.DrawTexture on GUI.Button press 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