private void Start() { mIsSelected = false; SelectImage.gameObject.SetActive(false); UGUIButtonEventTrigger.Get(gameObject).OnClick = go => { SetStatus(true); }; }
/// <summary> /// 弹出指定的 对话框模块 /// 此处会自动添加对话框半透明背景遮罩,并处理点击遮罩关闭 /// 所有使用当前类型弹框的内容放在Content节点下 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="callback"></param> /// <param name="isShowEffect">是否使用出现效果</param> /// <param name="isCanClickClose">是否可以点击空白处关闭</param> /// <param name="isShowTips">是否显示点击关闭提示,默认不提示</param> protected void PopupPanel <T>(Action <ModuleContext> callback = null, bool isShowEffect = true, bool isCanClickClose = true, bool isShowTips = false) where T : Module, new() { // if ((UIManager.tipGroup as RectTransformLayerGroup).GroupTransform.localPosition != new Vector3(0, 0, -1500)) // { // (UIManager.tipGroup as RectTransformLayerGroup).GroupTransform.localPosition = new Vector3(0, 0, -1500); // (UIManager.guideGroup as RectTransformLayerGroup).GroupTransform.localPosition = new Vector3(0, 0, -1500); // } Popup <T>(context => { var clickHandler = new GameObject("ClickHandler"); clickHandler.transform.SetParent(context.View.transform); clickHandler.transform.SetAsFirstSibling(); clickHandler.transform.localScale = Vector3.one; clickHandler.transform.localPosition = Vector3.zero; var iamge = clickHandler.AddComponent <Image>(); iamge.color = new Color(0, 0, 0, 0.7f); var clickRect = clickHandler.GetComponent <RectTransform>(); clickRect.sizeDelta = Vector2.zero; clickRect.anchorMin = Vector2.zero; clickRect.anchorMax = Vector2.one; if (isShowEffect) { var rectTransform = context.View.transform.Find("Content").GetComponent <RectTransform>(); rectTransform.localScale = new Vector3(0.1f, 0.1f, 0.1f); rectTransform.DOScale(Vector3.one, 0.15f).SetEase(Ease.InOutBack); } if (callback != null) { callback(context); } if (isCanClickClose) { if (isShowTips) { var tips = new GameObject("tips"); tips.transform.SetParent(clickHandler.transform); tips.transform.localScale = Vector3.one; tips.transform.localPosition = Vector3.zero; var textTips = tips.AddComponent <Text>(); textTips.text = "点击屏幕空白处关闭"; textTips.rectTransform.sizeDelta = new Vector2(1000, 200); textTips.rectTransform.anchoredPosition = new Vector2(0, -830); textTips.alignment = TextAnchor.MiddleCenter; textTips.fontSize = 40; var outLine = textTips.gameObject.AddComponent <Outline>(); outLine.effectColor = new Color(0, 0, 0, 255); outLine.effectDistance = new Vector2(2, 2); } UGUIButtonEventTrigger.Get(clickHandler).OnClick = go => { context.Controller.Close(); }; } }); }