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 moghes · Mar 18, 2013 at 01:16 PM · buttonguitexturelayer

Can I have a virtual area to act as a button?

Hello,

I am developing for android, I have GUItextures acting as buttons.. However I need at some places to select a virtual area to be a separate button. For now I am importing the button area(png) as a different guiTexture.

please check the picture! Thanks alt text

for example, I have the close button as a separate layer in photoshop.. but if i could select my desired area to act as a button. (of course appearing only in the scene view) check the second picture plz alt text

btn.jpg (36.9 kB)
btn2.jpg (35.9 kB)
Comment
Add comment · Show 4
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 GuyTidhar · Mar 18, 2013 at 01:24 PM 0
Share

D'you mean you wish to have a transparent area act as a button?

avatar image moghes · Mar 18, 2013 at 01:42 PM 0
Share

yeah just that :)

avatar image AlucardJay · Mar 18, 2013 at 01:50 PM 0
Share

Check my answer here : http://answers.unity3d.com/questions/377430/mul$$anonymous$$ch-area.html

avatar image moghes · Mar 18, 2013 at 03:01 PM 0
Share

thanks! that's a useful post :) thumbs up

3 Replies

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

Answer by GuyTidhar · Mar 18, 2013 at 01:45 PM

Use a button and set with with a transparent png (original size of 2x2 so it'll be small)

Comment
Add comment · Show 6 · 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 moghes · Mar 18, 2013 at 02:03 PM 0
Share

do you mean a gui.button? and that will have the default button display ..

avatar image GuyTidhar · Mar 18, 2013 at 02:07 PM 0
Share

I mean a GUI button (ok if you don't need many).

But ins$$anonymous$$d of using the default GUI look, you set the normal and hover images to the transparent png I've mentioned.

avatar image GuyTidhar · Mar 18, 2013 at 02:11 PM 1
Share

You can work with GUIStyle:

 public Rect yourClickableArea = new Rect (0,0,200,200);
 public Texture2D yourEmptyImage;

 void OnGUI()
 {
     GUIStyle guiStyle = new GUIStyle();
     guiStyle.normal.background = yourEmptyImage;
     guiStyle.hover.background = yourEmptyImage;
     if ( GUI.Button(yourClickableArea, "", guiStyle) )
     {
        // Stuff to do
     }
 }


You could also work with GUISkin if you are familiar with it. Basically you do the same thing by using it, since GUISkin holds a gui button style or your custom one.

avatar image moghes · Mar 18, 2013 at 02:47 PM 0
Share

thanks for your help! let me try working with GUIStyle

avatar image GuyTidhar · Mar 18, 2013 at 02:50 PM 0
Share

Sure thing mate.

Let me know if it works.

Show more comments
avatar image
1

Answer by MrSteve1 · Mar 18, 2013 at 02:09 PM

You can just make a transparent image and place that right where you need it.

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

Answer by PAHeartBeat · Mar 18, 2013 at 04:20 PM

you also can use just invisible rect like that

 Rect invisibleButton = new Rect(0,0,100,100);
 
 void Update(){
 if(invisibleButton.Contains(input.GetMosuseUp(0)){
 // do somithing
 }
 }
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

14 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

Related Questions

I Need a script for a guitexture enableing a spotlight and play a sound when pressed 1 Answer

Unable to reactive the game object 1 Answer

Resizing multiple GUI Textures to remain together 0 Answers

GUITexture OnMouseDown Problem 1 Answer

GUITextures and Triggers 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