Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by tarekhfahmi · Oct 12, 2017 at 09:44 PM · functionbuttonsbutton trigger eventsonclickload scene

I cant assign a function to a button. *free candy for whoever helps me out*

I cannot- for the life of me- assign a function to this button. i've tried everything. I've tried reloading unity, renaming the script, buttons, and empty game object that the button is assigned to. Nothing works. I'm trying to get it so that when i click the button, it loads another one of my scenes (and yes, I added it to my build already. I think my script should be fine but it isn't working. this is the script i'm using.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 public class ButtonManager : MonoBehaviour
 {
     public void NewGameButton(string newGameLevel)
     {
        SceneManager.LoadScene(newGameLevel);
     }
 }
 

After I attach it to an empty game object and then to the button,
alt text

and then i get the weird default stuff that i have no idea how to use (and doesnt work here anyways)

Please give me simple step by step instructions on how to fic this lol as im new to unity and scripting and im only 14 alt text

screenshot-15.png (104.5 kB)
screenshot-14.png (404.7 kB)
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 TSI25 · Oct 12, 2017 at 10:03 PM

I think you just want to click on this option

alt text

and then youll put in the name of the scene youre trying to load in the field that pops up.

as a side note you might also want to rename that function something like LoadScene so that its more recognizable.


capture.jpg (53.0 kB)
Comment
Add comment · Show 2 · 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 tarekhfahmi · Oct 12, 2017 at 10:19 PM 0
Share

Thank you so much! i gave you all the reputation points i could (1) lol but you really are a life saver. i also took your advice and renamed function. also i just wanted to ask- could i have your email? I know nobody who knows anything about c# or unity , and most of the online tutorials are made for people who are already experienced in c# and or unity.. You are a g o d s e n d.

avatar image pako tarekhfahmi · Jan 09, 2018 at 09:44 PM 0
Share

@tarekhfahmi if an answer solves your problem you must accept it, and probably also upvote it. This automatically awards much more reputation points than you manually give.

Please read the FAQ: https://answers.unity.com/page/faq.html

If you are just posting questions and are not accepting/upvoting answers/comments, people will notice after a while and might stop helping you.

avatar image
-1

Answer by SirPotoo · Dec 14, 2018 at 07:09 PM

Or maybe create a new gameobject and put this on it:

 using whatever blah blah;
     
     public button BUTTON; //creates a popup in inspector which will allow you to pick any button
 
     public class Whatever : MonoBehaviour {
 
        void start(){
        BUTTON.onClick.AddListener(MyScript);
        }
 
        void update(){
        }
 
        public void MyScript(){
        // your script
        }
     }
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

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

Related Questions

UI Button OnClick Only Works the First Time 2 Answers

Player Upgrade Screen - Button Upgrades keep resetting! 0 Answers

How to grab button object within Instantiated UI Template? 2 Answers

Can't change sprite image of a button 1 Answer

Buttons won't get interaction in instantiated prefab 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