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 /
This question was closed Sep 23, 2013 at 10:40 PM by clunk47 for the following reason:

Question is off-topic or not relevant

This post has been wikified, any user with enough reputation can edit it.
avatar image
4
Question by Triqy · Mar 22, 2013 at 05:09 AM · androidguibuttontouchcustom

Android GUITexture Touch

This little code is not a question, but rather a help answer. The code below is for new developers that are trying to make a GUI button for mobile devices. I thought it would be a good idea to help the newer people that are getting into game development. :) This code is in Java.

 #pragma strict
 
 static var ShowGUI = false;
 
 function Start () {
 
 ShowGUI = true;
 
 }
 
 function Update () {
 
 //The 'ShowGUI' enables you do either view or not view the actual GUI
 
 if(ShowGUI == true ){
 
 guiTexture.enabled = true;
 
 }else{
 
 guiTexture.enabled = false;
 
 }
 
 if(ShowGUI == true){
 
 if(Input.touchCount > 0 ){
 
 for(var i : int = 0; i < Input.touchCount; i++){
 
 var touch : Touch = Input.GetTouch(i);
 
 if(touch.phase == TouchPhase.Began &&
 guiTexture.HitTest(touch.position)){
 
 //This space is where the action happens when you touch your custom GUI button on
 //your device.
 
 }
 }
 }else{
 
 //Stops Action
 
 }
 }
 }

Just Copy/Paste above script into a JS script and place it on the GUITexture you have made in your scene and there you have it. A simple Custom button. :) Cheers!

Comment
Add comment · Show 6
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 Ngo · Aug 03, 2013 at 05:09 AM 2
Share

Well, this is helpful~!

avatar image devil304 · Sep 19, 2013 at 05:14 PM 2
Share

Thanks, I search this more time.

avatar image NickP_2 · Jan 09, 2014 at 11:13 AM 2
Share

You saved us days of headaches!

avatar image greenevo · Mar 02, 2014 at 06:41 PM 2
Share

thank you :-)

avatar image rodude123 · May 22, 2014 at 07:38 PM 1
Share

thanks so much

Show more comments

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

17 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 avatar image

Related Questions

Switching a GUIbuttons texture when holding your finger on it? 1 Answer

Button reaction time problem 1 Answer

Why this simple code doesnt work? 0 Answers

Holding GUI Button Touch to Rotate Object 0 Answers

GUI Button for Android 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