Exemplo n.º 1
0
    void CheckProcessingTime()
    {
        float averageTime = 0f;

        for (int i = 0; i < previousProcessingTimes.Length; i++)
        {
            averageTime += previousProcessingTimes[i];
        }
        averageTime /= (float)previousProcessingTimes.Length;

        if (averageTime > maxProcessingTime)
        {
            // reduce cookie resolution, unless it is already at the minimum
            if (cookieSize.ToString() != "c_128")
            {
                Debug.Log(gameObject.name + " is reducing cookie resolution from " + cookieSize.ToString() + " to " + (cookieSize - 1).ToString());
                cookieSize = (CookieSizes)(cookieSize - 1);
                cookie.SetCookieSize(int.Parse(cookieSize.ToString().Substring(2)));

                // reset the processing time array so we get a new measurement next time
                for (int i = 0; i < previousProcessingTimes.Length; i++)
                {
                    previousProcessingTimes[i] = 0f;
                }
            }
        }
        else
        {
            // we processed within the required time - set the flag to stop checking
            optimisedProcessingTimeYet = true;
        }
    }
Exemplo n.º 2
0
    void OnValidate()
    {
        if (!EditorApplication.isPlaying)
        {
            if (images.Count == 0) // ensure there is always at least 1 slot in the images array
            {
                images.Add(null);
            }
            if (cookies != null && cookies.Length > 0)
            {
                previewImageIndex = Mathf.Clamp(previewImageIndex, 0, images.Count - 1); // ensure PreviewImageIndex is valid

                if (live && cookies[slideshowIndex] != null)
                {
                    // preview image has changed?
                    if (images[previewImageIndex] != lastImage || previewImageIndex != lastPreviewImageIndex)
                    {
                        if (images[previewImageIndex])
                        {
                            cookies[0].SetProjectedImage(images[previewImageIndex]);
                        }
                        else
                        {
                            cookies[0].RemoveProjectedImage();
                        }
                    }
                    if (colour != lastColour)
                    {
                        UpdateColour();
                    }
                    // recalculate cookie
                    if (aspectRatio != lastAspect ||
                        throwRatio != lastThrowRatio ||
                        shift_h != lastShiftH ||
                        shift_v != lastShiftV ||
                        keystoneH != lastKeystoneH ||
                        keystoneV != lastKeystoneV ||
                        colour != lastColour ||
                        previewImageIndex != lastPreviewImageIndex ||
                        images[previewImageIndex] != lastImage)
                    {
                        cookies[0].Reinitialise(new CookieData(shift_v, shift_h, keystoneH, keystoneV, throwRatio, aspectRatio));

                        lastColour            = colour;
                        lastAspect            = aspectRatio;
                        lastThrowRatio        = throwRatio;
                        lastShiftH            = shift_h;
                        lastShiftV            = shift_v;
                        lastKeystoneH         = keystoneH;
                        lastKeystoneV         = keystoneV;
                        lastPreviewImageIndex = previewImageIndex;
                        lastImage             = images[previewImageIndex];
                        AssignLightCookies();
                    }
                    if (cookieSize != lastCookieSize)
                    {
                        cookies[0].SetCookieSize(int.Parse(cookieSize.ToString().Substring(2)));
                        lastCookieSize = cookieSize;
                        AssignLightCookies();
                    }
                    if (borderSize != lastBorderSize)
                    {
                        if (borderSize < 1)
                        {
                            borderSize = 1;
                        }
                        cookies[0].SetBorderSize(borderSize);
                        lastBorderSize = borderSize;
                    }
                    if (lastBrightness != brightness)
                    {
                        foreach (Light l in lights)
                        {
                            l.intensity    = brightness;
                            lastBrightness = brightness;
                        }
                    }
                    if (lastRange != range)
                    {
                        foreach (Light l in lights)
                        {
                            l.range   = range;
                            lastRange = range;
                        }
                    }
                    if (showLightPath != lastShowLightPath)
                    {
                        if (tb)
                        {
                            tb.gameObject.SetActive(showLightPath);
                        }
                        lastShowLightPath = showLightPath;
                    }
                }
            }
            // rebuild the light path geometry
            BuildLightPath();
        }
    }
Exemplo n.º 3
0
    void OnValidate()
    {
        if (!EditorApplication.isPlaying)
        {
            if (cookie != null)
            {
                if (live && cookie != null)
                {
                    // recalculate cookie
                    if (aspectRatio != lastAspect ||
                        throwRatio != lastThrowRatio ||
                        shift_h != lastShiftH ||
                        shift_v != lastShiftV ||
                        keystoneH != lastKeystoneH ||
                        keystoneV != lastKeystoneV)
                    {
                        cookie.Reinitialise(new CookieData(shift_v, shift_h, keystoneH, keystoneV, throwRatio, aspectRatio));

                        lastAspect     = aspectRatio;
                        lastThrowRatio = throwRatio;
                        lastShiftH     = shift_h;
                        lastShiftV     = shift_v;
                        lastKeystoneH  = keystoneH;
                        lastKeystoneV  = keystoneV;
                        AssignLightCookies();
                    }
                    if (cookieSize != lastCookieSize)
                    {
                        cookie.SetCookieSize(int.Parse(cookieSize.ToString().Substring(2)));
                        lastCookieSize = cookieSize;
                        AssignLightCookies();
                    }
                    if (lastBrightness != brightness)
                    {
                        foreach (Light l in lights)
                        {
                            l.intensity    = brightness;
                            lastBrightness = brightness;
                        }
                    }
                    if (lastRange != range)
                    {
                        foreach (Light l in lights)
                        {
                            l.range   = range;
                            lastRange = range;
                        }
                    }
                    if (borderSize != lastBorderSize)
                    {
                        if (borderSize < 1)
                        {
                            borderSize = 1;
                        }
                        cookie.SetBorderSize(borderSize);
                        lastBorderSize = borderSize;
                    }
                    if (showLightPath != lastShowLightPath)
                    {
                        if (tb)
                        {
                            tb.gameObject.SetActive(showLightPath);
                        }
                        lastShowLightPath = showLightPath;
                    }
                }
            }
            BuildLightPath();
        }
    }