• 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 skullred · Aug 15, 2013 at 06:28 PM · guitexturetexture2dmore

more guitexture in void ongui

I have to put multiple images on the screen (GUITexture) but as soon as I press play these images appear all at once, I would like to know: what the script to disable all the scripts to run only the image with a given name?

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 YoungDeveloper · Aug 15, 2013 at 06:56 PM

You should use OnGUI(), you can control gui textures or any other data in OnGui function using Bools.

 if(showpicture1){
 //gui picture 1 stuff }
 
 if(showpicture2){
 //gui picture 2 stuff }
Comment
Add comment · Show 5 · 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 skullred · Aug 15, 2013 at 07:12 PM 0
Share

you can write the full script? For example I have the images "help" and "help2" as the off / on?

avatar image YoungDeveloper · Aug 15, 2013 at 07:32 PM 0
Share
 public Texture2D help1; //drag image help 1 here
 public Texture2D help2; //drag image help 2 here
 
 bool show_help1;
 bool show_help2;
 
 void Start(){
 //images wont show as default
 
 show_help1 = false;
 show_help2 = false;
 
 }
 
 void Update(){
    if(Input.GetKeyDown(KeyCode.Mouse0)){
       show_help1 = true;
    }
    if(Input.GetKeyUp(KeyCode.Mouse0)){
       show_help1 = false;
    }
 
    if(Input.GetKeyDown(KeyCode.Mouse1)){
       show_help2 = true;
    }
    if(Input.GetKeyUp(KeyCode.Mouse1)){
       show_help2 = false;
    }
 }
 
 
 void OnGUI(){
 
 if(show_help1 == true){
 GUI.DrawTexture(new Rect(Screen.width-help1.width, Screen.height/2,help1.width,help1.height),help1);
 }
 
 if(show_help2 == true){
 GUI.DrawTexture(new Rect(0, Screen.height/2,help2.width,help2.height),help2);
 }

If you will hold down left mouse button, you will see help 1 image. But on right mouse button hold you will see help2 image.

avatar image skullred · Aug 16, 2013 at 10:59 AM 0
Share

the script works ok but how do I correctly position the image at the top right of the screen?

avatar image YoungDeveloper · Aug 16, 2013 at 11:13 AM 0
Share

Please read the docs before asking, i have a feeling that you are not even trying to understand. Everything you need is I already mentioned and even coded for you. http://docs.unity3d.com/Documentation/ScriptReference/Rect.html

 GUI.DrawTexture(new Rect(//distance from left screen side, //distance from upp screen side, //gui box width, gui box height), //image to show );
avatar image YoungDeveloper · Aug 16, 2013 at 11:18 AM 0
Share

So to get it on top right corner:

 GUI.DrawTexture(new Rect(Screen.width - help1.width, 0 , help1.width , help1,height),help1);

And remember to accept my answer.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

GUI Style Issue-- Texture not changing 2 Answers

Same BackGroung For All Screen Resolution 1 Answer

Select part of the texture in GUI.DrawTexture 2 Answers

Empty spaces in buttons are detected by mouse 2 Answers

Update Texture type to GUI during runtime 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