public T CreateDialog <T>(DialogEnum dialogType, DialogView.IDialogCallBack callBack, DialogBean dialogBean, float delayDelete) where T : DialogView { string dialogName = EnumUtil.GetEnumName(dialogType); GameObject objDialog = CreateDialog(dialogName); if (objDialog) { DialogView dialogView = objDialog.GetComponent <DialogView>(); if (dialogView == null) { Destroy(objDialog); } dialogView.SetCallBack(callBack); dialogView.SetData(dialogBean); if (delayDelete != 0) { dialogView.SetDelayDelete(delayDelete); } //改变焦点 EventSystem.current.SetSelectedGameObject(objDialog); listDialog.Add(dialogView); return(dialogView as T); } else { LogUtil.LogError("没有找到指定Toast:" + "Resources/UI/Toast/" + dialogName); return(null); } }
public T CreateDialog <T>(DialogEnum dialogType, Action <DialogView, DialogBean> actionSubmit, Action <DialogView, DialogBean> actionCancel, DialogView.IDialogCallBack callBack, DialogBean dialogBean, float delayDelete) where T : DialogView { string dialogName = EnumUtil.GetEnumName(dialogType); GameObject objDialogModel = manager.GetDialogModel(dialogName); if (objDialogModel == null) { LogUtil.LogError("没有找到指定Dialog:" + dialogName); return(null); } GameObject objDialog = Instantiate(gameObject, objDialogModel); if (objDialog) { DialogView dialogView = objDialog.GetComponent <DialogView>(); if (dialogView == null) { Destroy(objDialog); } dialogView.SetCallBack(callBack); dialogView.SetAction(actionSubmit, actionCancel); dialogView.SetData(dialogBean); if (delayDelete != 0) { dialogView.SetDelayDelete(delayDelete); } //改变焦点 EventSystem.current.SetSelectedGameObject(objDialog); manager.AddDialog(dialogView); return(dialogView as T); } else { LogUtil.LogError("没有实例化Dialog成功:" + dialogName); return(null); } }
/// <summary> /// 创建弹窗 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dialogBean"></param> /// <param name="delayDelete"></param> /// <returns></returns> public T CreateDialog <T>(DialogBean dialogBean) where T : DialogView { string dialogName = dialogBean.dialogType.GetEnumName(); GameObject objDialogModel = GetDialogModel(dialogName); if (objDialogModel == null) { LogUtil.LogError("没有找到指定Dialog:" + dialogName); return(null); } Transform tfContainer = GetUITypeContainer(UITypeEnum.Dialog); GameObject objDialog = Instantiate(tfContainer.gameObject, objDialogModel); if (objDialog) { DialogView dialogView = objDialog.GetComponent <DialogView>(); if (dialogView == null) { Destroy(objDialog); } dialogView.SetCallBack(dialogBean.callBack); dialogView.SetAction(dialogBean.actionSubmit, dialogBean.actionCancel); dialogView.SetData(dialogBean); if (dialogBean.delayDelete != 0) { dialogView.SetDelayDelete(dialogBean.delayDelete); } //改变焦点 EventSystem.current.SetSelectedGameObject(objDialog); dialogList.Add(dialogView); return(dialogView as T); } else { LogUtil.LogError("没有实例化Dialog成功:" + dialogName); return(null); } }