12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- 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<Renderer>();
- }
- 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");
- }
- }
- }
- /// <summary>
- /// 设置图片
- /// </summary>
- /// <param name="img"></param>
- public void SetImage(Texture2D img)
- {
- this.img = img;
- }
- }
- }
|