/// <summary> /// 出现选择项 /// </summary> private IEnumerator ShowSelection() { selectionContainer.transform.DestroyChildren(); int n = currentText.nextSelect.Count; //默认位置顺序:左右上下 int[] dx = { -200, 200, 0, 0 }; int[] dy = { 0, 0, 100, -100 }; //加载选项 for (int i = 0; i < n; i++) { NegotiateSelection ns = currentText.nextSelect[i]; //如果不满足前置的话题则跳过 if (!JudgeSelection(ns)) { continue; } //加载Label GameObject go = Resources.Load("Prefab/Select_Negotiate") as GameObject; go = NGUITools.AddChild(selectionContainer, go); go.transform.Find("Label").GetComponent <UILabel>().text = ns.selectName; //按钮获取 go.GetComponent <NegotiateSelectButton>().SetUIManager(this); //设定按下后的链接点 go.GetComponent <NegotiateSelectButton>().entranceNo = ns.negotiateNum; if (n == 1) { //单个选项位置 中间 go.transform.localPosition = Vector3.zero; } else { go.transform.localPosition = new Vector3(dx[i], dy[i]); } } selectionContainer.SetActive(true); //淡入 float t = 0; while (t < 1) { t = Mathf.MoveTowards(t, 1, 1 / 0.2f * Time.deltaTime); selectionContainer.GetComponent <UIWidget>().alpha = t; yield return(null); } }
/// <summary> /// 判断选项能否出现 /// </summary> private bool JudgeSelection(NegotiateSelection ns) { //获取当前的topic列表 return(true); }