using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using XRTool.Util; namespace XRTool.WorldUI { public class RendererImage : MonoBehaviour { private Renderer meshRender; public Texture2D img; public string texName = "_MainTex"; public Renderer MeshRender { get { if (!meshRender) { meshRender = GetComponent(); } return meshRender; } } private void Start() { if (MeshRender && img) { try { UnityUtil.ChangeMateTexture2D(MeshRender, img, texName); } catch (Exception ex) { UnityLog.Instance.LogError(MeshRender.material + " have no mainTexture"); } } } /// /// 设置图片 /// /// public void SetImage(Texture2D img) { this.img = img; } } }