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 angel2000 · Apr 20, 2014 at 01:15 AM · gui

GUI Text as Button

Hi There,

In need of major help, so ive made a menu with three GUI texts saying easy, medium and hard, what i want is that when ever the player taps one of the texts it loads a scene, this is the code i have already, but it wont work, the scene i want to go to is in the build settings.

using UnityEngine; using System.Collections;

public class EasyButton : MonoBehaviour {

 void OnMouseDown()
 {
     //load the level named "Tappy Plane New"
     Application.LoadLevel("Tappy Plane New");
 }

}

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 Eric5h5 · Apr 20, 2014 at 01:46 AM 0
Share

What about it doesn't work? What version of Unity are you using? Using On$$anonymous$$ouseDown for touch input isn't functional unless you're using Unity 4 or later.

avatar image angel2000 · Apr 20, 2014 at 01:47 AM 0
Share

Hi, im using unity 4, but every time i use the void On$$anonymous$$ouseDown function and try to click easy on my main men it doesnt go to tappy plane new

avatar image Eric5h5 · Apr 20, 2014 at 02:00 AM 0
Share

Did you do any basic debugging to see what's happening? Such as putting Debug.Log ("Used easy button") inside the On$$anonymous$$ouseDown function.

avatar image angel2000 · Apr 20, 2014 at 02:01 AM 0
Share

Nope, not sure how to really

avatar image Eric5h5 · Apr 20, 2014 at 02:21 AM 1
Share

Er...I just explained exactly how.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tw1st3d · Apr 20, 2014 at 01:17 AM

You need to use a GUI.Button(); GUI_Button_Style is optional.

In Javascript:

 function OnGUI() {
     if(GUI.Button( Rect( OFFSET-LEFT, OFFSET-TOP, WIDTH, HEIGHT), "GUI_BUTTON_TEXT", GUI_BUTTON_STYLE)) {
         Application.LoadLevel("Tappy Plane New");
     }
 }

In C#:

 void OnGUI() {
     if(GUI.Button(new Rect( OFFSET-LEFT, OFFSET-TOP, WIDTH, HEIGHT), "GUI_BUTTON_TEXT", GUI_BUTTON_STYLE)) {
         Application.LoadLevel("Tappy Plane New");
     }
 }
Comment
Add comment · Show 7 · 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 angel2000 · Apr 20, 2014 at 01:24 AM 0
Share

Hi,

I tried the button thing, and when I test it on my bb z10 device the buttons are really small, so I thought I would use gui text, any way that I can gui button fucntions to the gui text, without having the button style

avatar image angel2000 · Apr 20, 2014 at 01:29 AM 0
Share

Hi,

I tried the button thing, and when I test it on my bb z10 device the buttons are really small, so I thought I would use gui text, any way that I can gui button fucntions to the gui text, without having the button style

avatar image tw1st3d · Apr 20, 2014 at 01:30 AM 0
Share

Converted your answer to comment. Please remember to use the comment button under someones answer ins$$anonymous$$d. :)

avatar image tw1st3d · Apr 20, 2014 at 01:31 AM 0
Share

I'm unaware of any way to do that, however that does not mean that there is no way to do it. If I were you, I'd create a new GUISkin, and create a custom style for the buttons. You can adjust their font size, color, background image, and active/hover/focus states. Just create large enough buttons to be the proper size.

avatar image angel2000 · Apr 20, 2014 at 01:45 AM 0
Share

alright, i will try to do that again, cause i previously tried resizing it and it didnt make much of a difference. I washopeing to do it the gui text way but its alright

Show more comments

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

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

Related Questions

A node in a childnode? 1 Answer

Unity's GUI Icons are Blurry..? 1 Answer

GUI how to make the scrollbar bigger? 1 Answer

DragWindowPosition Doesn't Work 1 Answer

I am having an issue with returning an array 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