using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour {
public float allowance;
public Texture2D wallTexture;
private Texture2D tempTexture;
private float wall_height; // 【获图片宽高信息】
private float wall_width;
RaycastHit hitInfo;
void Start () {
wallTexture = GetComponent<MeshRenderer>().material.mainTexture as Texture2D;
wall_height = wallTexture.height;
wall_width = wallTexture.width;
tempTexture = Instantiate(wallTexture) as Texture2D;
GetComponent<MeshRenderer>().material.mainTexture = tempTexture;
}
void Update () {
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray,out hitInfo))
{
//获取鼠标点击到的像素的颜色
Vector2 uv = hitInfo.textureCoord;