void ShowUI() { EventTriggerListener.Get(InfoBtn.gameObject).OnClick += (go, data) => { bridgeInfo.GetComponent <Image>().DOFade(1, .3f); }; EventTriggerListener.Get(BackBtn.gameObject).OnClick += (go, data) => { mCurrentFocus = pos; mSphericalPos.r = 80; panelScript.gameObject.SetActive(false); BackBtn.GetComponent <Image>().DOFade(0, .3f); CameraActions.FocusAt(camera, mCurrentFocus, dir, mSphericalPos.r, .5f, t => { foreach (var mIcon in m_Icons) { mIcon.GetComponent <Image>().DOFade(1, .5f); } }); }; m_Icons.Clear(); var floatIconPrefab = Resources.Load <GameObject>("FloatIcon"); foreach (var focusInfo in infos) { var go = Instantiate(floatIconPrefab); go.transform.SetParent(FloatingRoot); m_Icons.Add(go.GetComponent <RectTransform>()); EventTriggerListener.Get(go).OnClick += (o, data) => { panelScript.gameObject.SetActive(true); panelScript.SetText(focusInfo.name, focusInfo.pos.y + "m", focusInfo.desc); BackBtn.GetComponent <Image>().DOFade(1, .5f); foreach (var mIcon in m_Icons) { mIcon.GetComponent <Image>().DOFade(0, .5f); } mSphericalPos.r = focusInfo.dist; mCurrentFocus = focusInfo.pos; CameraActions.FocusAt(Camera.main, focusInfo.pos, focusInfo.dir, focusInfo.dist, .5f, t => { }); }; } UpdateUI(); }
public static void Pop(string info) { if (script == null) { GameObject obj = GameObject.Find("InfoPanel"); if (obj != null) { script = obj.GetComponent <InfoPanelScript>(); if (script == null) { Debug.LogError("can not find InfoPanel with InfoPanelScript"); } } } if (script != null) { script.SetText(info); } }