using System.Collections; using System.Collections.Generic; using UnityEngine; using ZenFulcrum.EmbeddedBrowser; using UnityEngine.UI; //============================================================ //支持中文,文件使用UTF-8编码 //@author Zhaozibo //@create 20230131 //@company WT // //@description:看板展示脚本,需要在StreamingAssets文件下创建“看板地址管理.txt”文件, //里面需要填入前端提供的网页地址,bullerinBoards的数量需要和“看板地址管理”里中的链接 //数量一致。插件中提供链接参考。 //============================================================ namespace Controller { public class BulletinBoardController : MonoBehaviour { public Browser[] bullerinBoards; //获取网页传来得信息“SendMachineStationNumberToUnity”网页端必须有这个方法 // bullerinBoards[0].RegisterFunction("SendMachineStationNumberToUnity", (JSONNode jk)=>{function}); //调用网页上得方法“GetCurrentStationNumberFormUnity”网页端必须有这个方法 //bullerinBoards[3].CallFunction("GetCurrentStationNumberFormUnity", currentStationName).Done(); private void Start() { string[] urls = FileUtil.ReadAllFromLocal("看板地址管理.txt"); for (int i = 0; i < bullerinBoards.Length; i++) { int index = i; bullerinBoards[index].Url = urls[index+1]; } // bullerinBoards[0].RegisterFunction("SendMachineStationNumberToUnity", (JSONNode jk) => //{ // stationInformation.SwitchSelf(true); // currentStationName = jk[0].Value.ToString(); // if (MachineManager.Instance.GetMachineByName(currentStationName, out machineBase)) // { // target = machineBase.BoxCollider.bounds.center; // stationInformation.Init(target, currentStationName); // } // Debug.Log(jk[0].Value); //}); // stationInformation.selfBtn.onClick.AddListener(OnStationInformationClick); } //public void OnStationInformationClick() //{ // currentStationName = stationInformation.stationName.text; // bullerinBoards[3].CallFunction("GetCurrentStationNumberFormUnity", currentStationName).Done(); // informationToggle.isOn = true; // stationInformation.SwitchSelf(false); //} } }