- 在Canvas中创建Button和Text
- 写C#script代码
// To use this example, attach this script to an empty GameObject. // Create three buttons (Create>UI>Button). Next, select your // empty GameObject in the Hierarchy and click and drag each of your // Buttons from the Hierarchy to the Your First Button, Your Second Button // and Your Third Button fields in the Inspector. // Click each Button in Play Mode to output their message to the console. // Note that click means press down and then release. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Button : MonoBehaviour { //Make sure to attach these Buttons in the Inspector public Button m_YourFirstButton, m_YourSecondButton, m_YourThirdButton; public Text m_MyText; void Start() { //Calls the TaskOnClick/TaskWithParameters/ButtonClicked method when you click the Button m_MyText.text = "This
Unity 点击Button改变Text的显示内容
最新推荐文章于 2024-04-19 23:30:00 发布
