using UnityEngine;
using System.Collections;
public class SendLine : MonoBehaviour {
public Vector3 targetPoint;
private Transform MyTransform;
public Texture2D TextureMap;
void Start ()
{
MyTransform = GetComponent<Transform>();
}
void Update ()
{
sendLineMeth();
}
void sendLineMeth()
{
RaycastHit hit;
if( Physics.Raycast(MyTransform.position, -MyTransform.up,out hit,10f))
{
targetPoint= hit.point;
Debug.DrawLine(MyTransform.position, targetPoint);
//涂色
Vector2 pixelUV = hit.textureCoord;
pixelUV.x *= TextureMap.width;
pixelUV.y *= TextureMap.height;
TextureMap.SetPixel((int)pixelUV.x, (int)pixelUV.y,Color.red);
Debug.Log(pixelUV);
TextureMap.Apply();
}
}
}
unity 改变纹理像素点的颜色
最新推荐文章于 2024-03-20 16:21:33 发布