一个关于unity的问题,希望有回答

我想要的效果:点击“彩蛋”按钮打开愤怒的小鸟.exe,但是运行后点击不知道为啥不可以
Button

img

Button的代码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ButtonEvent : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    void OnClick()
    {
        string url = Application.dataPath + "/愤怒的小鸟.exe"; 
        Application.OpenURL(url); //打开
    }
}

img


    public void OnClick()
    {
        print("点击、、、、");
    }

img

这个方法根本没有执行,因为你的按钮没有监听这个方法

img

按钮使用的相关博文推荐: