Exemple #1
0
    public T CreateLoadingDialog <T>() where T : View <ViewModelBase>, ILoadingDialog
    {
        if ((_loadingDialog as MonoBehaviour) != null && !(_loadingDialog is T))
        {
            CloseLoadingDialog();
        }

        if ((_loadingDialog as MonoBehaviour) == null)
        {
            var t    = typeof(T).GetCustomAttributes(typeof(ResourcePathAttribute), false);
            var attr = t.FirstOrDefault() as ResourcePathAttribute;

            if (attr == null)
            {
                throw new Exception("Can't create loading dialog: attribute resources not defined " +
                                    typeof(T).Name);
            }

            var prefab = attr.IsLocalResource
                ? Resources.Load <GameObject>(attr.Path)
                : ResourceStorage.Instance.Get <GameObject>(attr.Path);

            _loadingDialog = AddToDialog <T>(prefab);
            var go = ((Component)_loadingDialog).gameObject;
            NGUITools.AdjustDepth(go, GuiConstants.Depths.LoadingDialog);
            _dialogManager.SetCurrentDialog(_loadingDialog as IView);
        }

        return(_loadingDialog as T);
    }
Exemple #2
0
    public void CloseLoadingDialog()
    {
        if (_loadingDialog == null)
        {
            return;
        }

        _dialogManager.CloseDialog(_loadingDialog as IView);
        _loadingDialog = null;
    }