Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question OnClick not showing the functions in script

Discussion in 'Scripting' started by johnnysuriano, May 31, 2024.

  1. johnnysuriano

    johnnysuriano

    Joined:
    May 13, 2024
    Posts:
    14
    I had a TextMashPro button to my project, and out code it to switch scene, but under the on click and function, it showed no functions

    NextSceneScript Code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class NextSceneScript : MonoBehaviour
    7. {
    8.  
    9.     public void NextScene()
    10.     {
    11.         SceneManager.LoadScene("Main");
    12.     }
    13.  
    14.     // Start is called before the first frame update
    15.     void Start()
    16.     {
    17.        
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.        
    24.     }
    25. }
    26.  
    Screenshot 2024-05-31 202237.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
  3. johnnysuriano

    johnnysuriano

    Joined:
    May 13, 2024
    Posts:
    14
    I tried following your images but whenever I brought the gameObject with the script in to the button, and sets the function, it turns it back into a script and doesn't work