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 androids · Apr 30, 2013 at 11:59 PM · guitexturetouch

GUI Texture Touch Android

Hi guys,

I got a couple of GUI textures in 1 script and I want that each texture has his own function. By example. If you touch GUITexture_01, you go to Scene_01 and if you touch GUITexture_02, you go to Scene_02.

This is the script I use, but I couldn't find a solution.

     var Season_01:Texture2D : Touch = Input.touches[0];
     var Season_01Width:float = 100;
     var Season_01Height:float = 100;
     
     var Season_02:Texture2D : Touch = Input.touches[0];
     var Season_02Width:float = 100;
     var Season_02Height:float = 100;
     
     function OnGUI(){
      
            GUI.DrawTexture(Rect( (Screen.width - Season_01Width)*0.05,(Screen.height - Season_01Height)*0.3, Season_01Width, Season_01Height), Season_01);
            GUI.DrawTexture(Rect( (Screen.width - Season_02Width)*0.15,(Screen.height - Season_02Height)*0.3, Season_02Width, Season_02Height), Season_02);
     }
 
 function Update () {
     if(Input.touchCount >= 0) {
         if(Season_01.phase == TouchPhase.Began)
         {
             Application.LoadLevel("Scene_01");
         }
         if(Season_02.phase == TouchPhase.Began)
         {
             Application.LoadLevel("Scene_02");
         }
     }
 }

Someone who can tell me what I did wrong and can help me figure this out? Please HELP!.

Thanks in advance

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

2 Replies

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

Answer by androids · May 01, 2013 at 08:25 PM

I figured it out, but thanks for help. This is what it should be.

     var MenuSkin:GUISkin;
     var Season_01:Texture2D;
     var Season_01Width:float = 100;
     var Season_01Height:float = 100;
  
     var Season_02:Texture2D;
     var Season_02Width:float = 100;
     var Season_02Height:float = 100;
  
 function OnGUI () {
         GUI.skin = MenuSkin;
         
         if(GUI.Button(Rect( (Screen.width - Season_01Width)*0.05,(Screen.height - Season_01Height)*0.3, Season_01Width, Season_01Height), Season_01)){
             Application.LoadLevel("Scene_01");
         }
         if(GUI.Button(Rect( (Screen.width - Season_02Width)*0.15,(Screen.height - Season_02Height)*0.3, Season_02Width, Season_02Height), Season_02)){
             Application.LoadLevel("Scene_02");
         }
 }
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 androids · May 01, 2013 at 10:15 PM 0
Share

I tried that, I changed 'theTransparentGUIStyle' in to '$$anonymous$$enuSkin', but it gives me the same error '$$anonymous$$ identifier: '$$anonymous$$enuSkin'.

So I did it in this way. But thanks a lot!

avatar image
0

Answer by trs9556 · May 01, 2013 at 01:22 AM

I'm not sure how to do that with a drawTexture but you can use a Button with a custom skin. Inside that custom skin just make all the button styles a transparent image, doesn't have to be big can even be a few pixels; just 100% transparent.

Then just instead of GUI.DrawTexture use

 if(GUI.Button(Rect( (Screen.width - Season_01Width)*0.05,(Screen.height - Season_01Height)*0.3, Season_01Width, Season_01Height), Season_01, theTransparentGUIStyle)){
     Application.LoadLevel("Scene_01");
 }
 if(GUI.Button(Rect( (Screen.width - Season_02Width)*0.15,(Screen.height - Season_02Height)*0.3, Season_02Width, Season_02Height), Season_02, theTransparentGUIStyle)){
     Application.LoadLevel("Scene_02");
 }

Please excuse any errors, I code in C# not in JS, so I can't garentee that is copy and paste-able

Comment
Add comment · Show 3 · 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 androids · May 01, 2013 at 01:52 AM 0
Share

It doesn't work, I have no idea what's wrong and how to correct this JS

avatar image trs9556 · May 01, 2013 at 02:27 AM 0
Share

Have you made a new gui style and named it theTransparentGUIStyle?

avatar image androids · May 01, 2013 at 07:14 AM 0
Share

Yes I did, but it says, $$anonymous$$ identifier: 'theTransparentGUIStyle'.

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

13 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

Related Questions

GUITextures and Multi Touch 1 Answer

Touch Input with GUI Texture 1 Answer

GUI texture touch input problem 1 Answer

GuiTexture (Touch button) unfollow camera! 1 Answer

Touchscreen for unity 2 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