Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 technano · Jun 02, 2016 at 03:59 PM · uibuttons

Having issues with the UI Button?

So I'm having a lot of trouble with the UI Button right now, all I'm trying to do is add a button to change the scene to something else.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class UIManagerScript : MonoBehaviour 
 {
     public void GoTo()
     {
         Debug.Log ("Clicked");
         SceneManager.LoadScene (1);
     }
 }
 

I see other people using.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class UIManagerScript : MonoBehaviour 
 {
     public void GoTo()
     {
         Debug.Log ("Clicked");
         Application.loadLevel (1);
     }
 }
 

But neither of these ways works. Also when I try to go into playmode just to see the buttons highlight, nothing happens. It's like the buttons don't have a raycast or anything like that. Idk I haven't used UI elements at all so I have no idea how to use them. If someone could help me that would be greatly appreciated! Thank you

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 JigneshKoradiya · Jun 03, 2016 at 12:02 PM 0
Share

hi

first your button must be on top layer of canvas so it will not covered by other ui components

and select goto() method for button from inspector (i think you forgot it)

is "clicked" debug when you press button ?

avatar image technano JigneshKoradiya · Jun 04, 2016 at 10:49 PM 0
Share

Yeah I just have the "clicked" there so I could see if it was being clicked at all, and I tried moving the button to a different layer but no luck there either.

avatar image Mmmpies · Jun 03, 2016 at 12:11 PM 0
Share

Put your script on the Button- just drag it on there. Then select the button and look in the inspector and click + on the OnClick event.

A slot appears, now even though you have the button selected drag the button onto that slot. Then from the drop down select

UI$$anonymous$$anagerScript -> GoTo

Now when clicked the button will call that scripts GoTo function. REally look at the EventSystem tutorials as it's fantastic.

avatar image technano Mmmpies · Jun 04, 2016 at 10:51 PM 0
Share

I tried this and to no luck. I'll have to go to that tutorial to try and get a better understanding of it all.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by shanzebali · Jun 05, 2016 at 10:38 AM

Assign this function to the button, and add the scene to your build settings. If it debugs log "clicked".

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 technano · Jun 06, 2016 at 05:10 AM

I feel very foolish but I found the solution. I had deleted the eventsystem, now that it's back everything works fine!!

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Please help! After build on Android UI buttons can't enable/disable script but works when using Unity remote. 0 Answers

Menu not getting Keyboard Input 0 Answers

Buttons don't trigger only in build 0 Answers

UI buttons covers each other because of their order 1 Answer

How to convert a Mouse Input Combo System to Button? 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