Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        private void UpdatePickedColor(PickedColorCallback cb)
        {
            GameObject hitObject = GazeManager.Instance.HitObject;

            if (hitObject != rendererComponent.gameObject)
            {
                return;
            }

            //TODO: Fix by adding RaycastHit properties to FocusDetails.
            //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);
        }
Пример #4
0
        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);
        }
Пример #5
0
    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);
    }