41 lines
873 B
C#
41 lines
873 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);
|
|
});
|
|
}
|
|
|
|
public void OnButtonClick()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|