Home > other >  In the unity3d for reaction and then click the button to add the script, why not
In the unity3d for reaction and then click the button to add the script, why not

Time:09-18

Script:
using UnityEngine;
using System.Collections;
Using UnityEngine. SceneManagement;
//

Public class UI: MonoBehaviour {
Void the Start () {

}
Void the Update () {

}



Void OnButtonClick () {
SceneManager. LoadScene (" 12 ");
}
}
Method is the script to the additional game object STARTUI into the game of Onclick
So no response, press the button or the original scene
But if I put OnButtonClick () the function in the Start () or Update () began to run just jump straight to 12 this scene inside
To solve the

CodePudding user response:

Object up, still have to specify your function, do not specify a function, the unity which don't know what do you want to perform the function

CodePudding user response:

Dynamically add AddListener

CodePudding user response:

You don't have to monitor events, is to use NGUI or UGUI, NGUI need to add BoxCollider, UGUI painting directly dragging or add Addlistener

CodePudding user response:

With a click event

CodePudding user response:

Using AddListener add listening? Or on the Unity panel Button Button to add a click event, will you write the Button event method binding to it? As a good, the two methods have?

CodePudding user response:

Button need to add click on listening, advice or to understand the script of the meaning of the life cycle and every method to do it,,,

CodePudding user response:

You click no callback, you can add the callback function under the button click event

CodePudding user response:

Are you bound method?

CodePudding user response:

Direct the OnClick (); On line, click on the Button,
  • Related