Exemple #1
0
 public static WidgetManager GetInstance()
 {
     if (instance == null)
     {
         instance = new GameObject(typeof(WidgetManager).Name).AddComponent <WidgetManager>();
         DontDestroyOnLoad(GetInstance().gameObject);
     }
     return(instance);
 }
Exemple #2
0
        public void Update()
        {
            switch (state)
            {
            case State.Loading:
                if (_request.isDone)
                {
                    if (_request.error != null)
                    {
                        state = State.Destroyed;
                    }
                    else
                    {
                        gameObject = GameObject.Instantiate(_request.asset as GameObject);
                        state      = State.Loaded;
                        if (Onloaded != null)
                        {
                            Onloaded(this);
                        }
                    }
                }
                break;

            case State.Loaded:

                break;

            case State.Destroyed:
                if (gameObject != null)
                {
                    GameObject.Destroy(gameObject);
                    gameObject = null;
                }
                foreach (var item in assets)
                {
                    item.Value.Release();
                }
                _request.Release();
                _request = null;
                assets.Clear();
                WidgetManager.Remove(this);
                break;

            default:
                break;
            }
        }
Exemple #3
0
 public Widget(string assetPath)
 {
     _request = Assets.LoadAssetAsync(assetPath, typeof(GameObject));
     state    = State.Loading;
     WidgetManager.Add(this);
 }