unity中怎么给按钮添加点击事件

unity中怎么给按钮添加点击事件,第1张

ing System.Collections

using UnityEngine.UI

/// <summary>

/// 脚本位置:UGUI的按钮身上

/// 脚本功能:动态的添加按钮的点击事件

/// </summary>

public class Liste

var customSkin:GUISkin

function OnGUI () {

if(GUI.Button(Rect(Screen.width/2-50, Screen.height/2+200, 100,50), "Play game"))

{

print("You clicked me")

Application.LoadLevel(1)

}

//GUI.Button(Rect(Screen.width/2-50, Screen.height/2+260, 100,50), "exit game")

if(GUI.Button(Rect(Screen.width/2-50, Screen.height/2+260, 100,50), "exit game"))

{

print("You clicked me")

Application.LoadLevel(2)

}

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/8016027.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-12
下一篇2023-04-12

发表评论

登录后才能评论

评论列表(0条)

    保存