Announcement

Collapse
No announcement yet.

ButtonScript issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ButtonScript issue

    So I'm working on the Scene scripts of my final and I'm now working on my buttons script. My ButtonScript is this

    PHP Code:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.SceneManagement;

    public class 
    ButtonScript MonoBehaviour
    {

        
    void Start()
        {
            
    SceneManager.LoadScene("Game"LoadSceneMode.Single);
        }

        
    void About()
        {
            
    SceneManager.LoadScene("AboutScene"LoadSceneMode.Single);
        }

        
    void Quit()
        {
            
    Application.Quit();
        }

        
    void Home()
        {
            
    SceneManager.LoadScene("MainMenu"LoadSceneMode.Single);
        }

        
    void Enemies()
        {
            
    SceneManager.LoadScene("Enemy"LoadSceneMode.Single);
        }

        
    void HowToPlay()
        {
            
    SceneManager.LoadScene("HowToPlay"LoadSceneMode.Single);
        } 
    I've put the script on a gameobjected titled ButtonHolder and on my button I would drag it into my OnClick () box, my Script name ButtonScript appears in the function area but the names of my commands won't appear as shown below. Is there a way to fix this
    Click image for larger version

Name:	Annotation 2020-05-01 215655.jpg
Views:	12
Size:	46.1 KB
ID:	344668

  • #2
    You're on the right track. A few things:

    1) Don't name a method "Start". That is a sacred name to Unity and will do things you don't want it to in the way you're using it here. Change that function to StartGame or something like that.
    2) You won't see any of those methods because they aren't public. So make each method "public void About()", etc....then you should be able to see them in the editor.

    Comment


    • #3
      Thanks but now my other problem is that my buttons on my about scene seem unresponsive. The highlight and pressed images I assigned don't appear and even clicking won't do anything. My main menu is working find but not my other scenes. Here is the box of the circle buttons on my about scene
      Click image for larger version

Name:	Annotation 2020-05-02 110014.jpg
Views:	12
Size:	46.4 KB
ID:	344675

      Comment


      • #4
        Are there any errors appearing in the Console when you click a button?

        Comment


        • #5
          No, nothing appeared in the console

          Comment


          • #6
            If you're sure you have all those scenes in the Build Manager, I'd have to see it to diagnose more. C'mon by my Zoom Room.

            Comment

            Working...
            X