Ejemplo n.º 1
0
    Quaternion ClampRotationAroundXAxis(Quaternion q)
    {
        q.x /= q.w;
        q.y /= q.w;
        q.z /= q.w;
        q.w  = 1.0f;

        float angleX = 2.0f * Mathf.Rad2Deg * Mathf.Atan(q.x);

        angleX = verticalRotationRange.Clamp(angleX);

        q.x = Mathf.Tan(0.5f * Mathf.Deg2Rad * angleX);

        return(q);
    }
    public IEnumerator Show(VideoPlayer player, RangeFloat interval, Color color)
    {
        Assert.IsNotNull(image);
        image.color = color;

        float NormalizedTime(float time) => (float)(time / player.length);

        var   rt         = GetComponent <RectTransform>();
        float anchorMinX = NormalizedTime(interval.min);

        rt.anchorMin = new Vector2(anchorMinX, 0.0f);
        rt.anchorMax = new Vector2(anchorMinX, 1.0f);

        while ((float)player.time <= interval.max)
        {
            rt.anchorMax = new Vector2(NormalizedTime(interval.Clamp((float)player.time)), 1.0f);
            yield return(null);
        }
    }