彬哥和你一起學(xué)習(xí)U3D開發(fā)(3)--按鈕控件使用
一、 C#腳本 代碼如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class binge : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Click_test()
{
Debug.Log("點擊測試");
}
}
復(fù)制代碼
二夜焦、按鈕控件創(chuàng)建
<ignore_js_op style="overflow-wrap: break-word; color: rgb(68, 68, 68); font-family: "microsoft yahei"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">
</ignore_js_op>
三废登、腳本掛接到空間上
<ignore_js_op style="overflow-wrap: break-word; color: rgb(68, 68, 68); font-family: "microsoft yahei"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">
</ignore_js_op>
四、 腳本綁定事件
<ignore_js_op style="overflow-wrap: break-word; color: rgb(68, 68, 68); font-family: "microsoft yahei"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">
</ignore_js_op>
五铝条、 點擊測試
<ignore_js_op style="overflow-wrap: break-word; color: rgb(68, 68, 68); font-family: "microsoft yahei"; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">
</ignore_js_op>
六、 源碼
[#### 本帖隱藏的內(nèi)容
https://github.com/Golangltd/codeclass](https://github.com/Golangltd/codeclass)