Unity使用内嵌网页插件按钮层级设置的比插件低的时候解决办法
插件是[3D WebView]
按钮的层级设置要比插件低
按钮要写成如下代码进行点击
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public enum enumBQ { none,烟感,喷头 } public class UI_Label : MonoBehaviour { public enumBQ enumBQ; public string text; public Image image; //用的着就拖上去 public RectTransform trans; // Start is called before the first frame update void Start() { trans = this.transform.GetComponent<RectTransform>(); } void BtnClicks() { switch (enumBQ) { case enumBQ.none: break; case enumBQ.烟感: LoadHTMLCro.Instance.PostMessages("unity-ygdata", this.name, this.name); break; case enumBQ.喷头: LoadHTMLCro.Instance.PostMessages("unity-ptdata", this.name, this.name); break; default: break; } } private void Update() { if (Input.GetMouseButtonDown(0)) { // 判断是否点在 UI 上 //if (EventSystem.current.IsPointerOverGameObject()) return; // 或 RectTransform 区域判断 if (RectTransformUtility.RectangleContainsScreenPoint(trans, Input.mousePosition)) { BtnClicks(); Debug.Log("BTNNNNN_________"); } } } }

浙公网安备 33010602011771号