ShanDongVirtualPowerPlant/u3d-ShanDongVirtualPowerPlant/Assets/Adam/Scripts/WebAdapter.cs

41 lines
929 B
C#

using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Events;
public class WebAdapter : MonoBehaviour
{
#if UNITY_WEBGL && !UNITY_EDITOR
public string head;
public string token;
[DllImport("__Internal")]
private static extern void OnLevelChange(string level);
#else
public string head;
public string token;
private static void OnLevelChange(string level)
{
Debug.Log(level);
}
#endif
public UnityEvent<string> onStation;
public void LevelChange(string level)
{
OnLevelChange(level);
}
public void OnStation(string station)
{
onStation?.Invoke(station);
}
public void SetHeadAndToken(string _headAndToken)
{
string[] data = _headAndToken.Split("+");
head = data[0].Replace(" ", "");
token = data[1].Replace(" ", "");
}
}