void UpdatePickedColor(PickedColorCallback cb) { var headPosition = Camera.main.transform.position; var gazeDirection = Camera.main.transform.forward; RaycastHit hit; if (!Physics.Raycast(headPosition, gazeDirection, out hit)) { return; } if (hit.transform.gameObject != rendererComponent.gameObject) { return; } Texture2D texture = rendererComponent.material.mainTexture as Texture2D; Vector2 pixelUV = hit.textureCoord; pixelUV.x *= texture.width; pixelUV.y *= texture.height; Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y); cb.Invoke(col); SendMessageUpwards("OnColorCommand", col); }
void UpdatePickedColor(PickedColorCallback cb) { RaycastHit hit = GazeManager.Instance.HitInfo; if (hit.transform.gameObject != rendererComponent.gameObject) { return; } Texture2D texture = rendererComponent.material.mainTexture as Texture2D; Vector2 pixelUV = hit.textureCoord; pixelUV.x *= texture.width; pixelUV.y *= texture.height; GazedColor = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y); cb.Invoke(GazedColor); }
void UpdatePickedColor(PickedColorCallback cb) { RaycastHit hit = GazeManager.Instance.HitInfo; if (hit.transform != null && hit.transform.gameObject != rendererComponent.gameObject) { return; } voice.Play(); Vector2 pixelUV = hit.textureCoord; pixelUV.x *= texture.width; pixelUV.y *= texture.height; Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y); cb.Invoke(col); }
void UpdatePickedColor(PickedColorCallback cb) { // if not hit, return RaycastHit hit = GazeManager.Instance.HitInfo; if (hit.transform.gameObject != rendererComponent.gameObject) { return; } // get color from texture pixel and callback Texture2D texture = rendererComponent.material.mainTexture as Texture2D; Vector2 pixelUV = hit.textureCoord; pixelUV.x *= texture.width; pixelUV.y *= texture.height; Color col = texture.GetPixel((int)pixelUV.x, (int)pixelUV.y); cb.Invoke(col); }
public void SetColor(Color c) { OnPickedColor.Invoke(c); }