usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassTent:MonoBehaviour{publicCamera camera;// Start is called before the first frame updatevoidStart(){}// Update is called once per frame[System.Obsolete]voidUpdate(){SendUnityMessage();}/// <summary>/// 发送数据到Web端/// </summary>[System.Obsolete]publicvoidSendUnityMessage(){// 当前游戏对象的位置Vector3 worldPoint = transform.position;// 转换为屏幕位置Vector3 screenPoint = camera.WorldToScreenPoint(worldPoint);// w屏宽, h屏高, x位置, y位置Vector4 position =newVector4(Screen.width, Screen.height, screenPoint.x, Screen.height - screenPoint.y);// 发送到Web端Application.ExternalCall("updatePosition2Web", transform.gameObject.name, position);}/// <summary>/// 接收来自Web的传参/// </summary>/// <param name="message">传参信息</param>publicvoidReceiveWebMessage(string message){transform.position = Vector3.zero;Debug.Log(message);}}