Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. public class PixelGetter : MonoBehaviour {
  2.  
  3.     Ray _ray;
  4.     RaycastHit _hit;
  5.     Renderer _renderer;
  6.     public CRT_LEVEL1 crt;
  7.     // Use this forendererr initialization
  8.     void Start () {
  9.         _ray = new Ray(transform.position, Vector3.down);
  10.         _renderer = GetComponent<Renderer>();
  11.     }
  12.    
  13.     // Update is called once per frame
  14.     void Update () {
  15.         _ray.origin = transform.position;
  16.         if (Physics.Raycast(_ray, Mathf.Infinity, LayerMask.GetMask("Shaded")))
  17.         {
  18.             //remplace ça par ta fonction a toi
  19.             _renderer.material.color = crt.texture.GetPixel((int)_hit.textureCoord.x, (int)_hit.textureCoord.y);
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement