ChangDaoZhanGuan/ChangDaoPro/Assets/Scr/LightingControl.cs

45 lines
887 B
C#

using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
public class LightingControl : MonoBehaviour
{
public string num;
string str = "unity调用JS";
// 声明导入的JavaScript函数
[DllImport("Internal")]
private static extern void OpenWebPanel(string str);
// Start is called before the first frame update
void Start()
{
GetComponent<Button>().onClick.AddListener(() =>
{
//#if !UNITY_EDITOR
// // 在按钮点击时调用JavaScript函数
// OpenWebPanel(num);
//#endif
print("调用前端方法" + num);
Application.ExternalCall("OnButtonClick", num, name);
});
}
public void OnButtonClick()
{
}
// Update is called once per frame
void Update()
{
}
}