Esempio n. 1
0
    /// <summary>Called when asked to fade.</summary>
    public override void Load(string url, Dictionary <string, object> globals)
    {
        // Element is not null when we 'hijacked' an existing widget (and we're fading from its current color instead).
        if (element == null)
        {
            // Write the HTML now:
            SetHtml("<div style='width:100%;height:100%;position:fixed;top:0px;left:0px;'></div>");
        }

        // Don't run the load event - we're delaying it:
        RunLoad = false;

        // Get the colour:
        UnityEngine.Color colour = GetColour("to", globals, UnityEngine.Color.black);

        // Get the time:
        float time = (float)GetDecimal("time", globals, 0);

        // Run the animation:
        element.animate("background-color:" + colour.ToCss() + ";", time).OnDone(delegate(UIAnimation animation){
            // If the opacity is 0, close the widget:
            if (colour.a <= 0.001f)
            {
                close();
            }

            // Run the load event now!
            LoadEvent(globals);
        });
    }