AppManager.cs 1.08 KB
using UnityEngine;
using System.Collections;

public class AppManager : Singleton<AppManager>
{
    public ServerCanvasManager serverCanvas;
    public AppSettings appSettings;
    
    public void SpawnServerCanvas()
    {
        Instantiate(serverCanvas);
    }

    public void DestroyServerCanvas()
    {
        if (serverCanvas != null)
            Destroy(serverCanvas.gameObject);
    }
    
    public void TweenCanvasGroup(CanvasGroup group, float alpha, float time)
    {
        TweenCanvasGroup(group, alpha, time, null);
    }

    public void TweenCanvasGroup(CanvasGroup group, float alpha, float time, System.Action onComplete)
    {
        iTween.Stop(group.gameObject);

        Hashtable hash = new Hashtable()
        {
            { "from", group.alpha },
            { "to", alpha },
            { "time", time },
            { "onupdate", (System.Action<object>)(x => group.alpha = (float) x) }
        };

        if (onComplete != null)
            hash.Add("oncomplete", (System.Action<object>)(x => onComplete()));

        iTween.ValueTo(group.gameObject, hash);
    }
}