public void changeSize() { basePanel menu = null; try { menu = transform.parent.gameObject.GetComponent <basePanel>(); menu.changeSize(); } catch { if (menu == null) { float s = gameManager.instance.setting.windowSize; if (gameManager.instance.setting.windowSize == gameManager.instance.maxSize) { float w = Screen.width / gameManager.instance.width; float h = Screen.height / gameManager.instance.height; s = (w < h) ? w : h; } transform.localScale = startScale / gameManager.instance.oriSize * s; transform.localPosition = startPosition / gameManager.instance.oriSize * s; } } }
override protected void init() { optionNum = 7; doFuncs = new Func[optionNum]; doFuncs[0] = new Func(changeBool); doFuncs[1] = new Func(changeBool); doFuncs[2] = new Func(addValue); doFuncs[3] = new Func(addValue); doFuncs[4] = new Func(addValue); doFuncs[5] = new Func(changeLanguage); doFuncs[6] = new Func(exit); otherFuncs[0] = new Func(_cancel); otherFuncs[1] = new Func(_cancel); otherFuncs[2] = new Func(_right); otherFuncs[3] = new Func(moveUp); otherFuncs[4] = new Func(moveDown); mainPanel = UIManager.instance.getMainMenu().GetComponent <basePanel>(); //初始化UI数值 musicText.text = Mathf.RoundToInt(gameManager.instance.setting.musicValue * 10) + "0%"; SEText.text = Mathf.RoundToInt(gameManager.instance.setting.SEValue * 10) + "0%"; if (gameManager.instance.setting.windowSize == gameManager.instance.maxSize) { sizeText.text = "全屏"; } else { sizeText.text = "x " + gameManager.instance.setting.windowSize; } if (gameManager.instance.setting.alwaysRun) { runText.text = "ON"; } else { runText.text = "OFF"; } if (gameManager.instance.setting.autoMessage) { autoMessageText.text = "ON"; } else { autoMessageText.text = "OFF"; } langText.text = gameManager.instance.setting.nowlang.ToString(); afterDis = delegate { Destroy(gameObject); }; }
//显示任意菜单 public GameObject showAnyPanel(GameObject _panel, Vector2 _pos, bool mainUI) { if (gameManager.instance.nowstate != nowState.window || mainUI) { GameObject go = GameObject.Instantiate(_panel) as GameObject; gameManager.instance.changeState(nowState.window, go); go.transform.SetParent(GameObject.Find("Canvas").GetComponent <RectTransform>()); basePanel basepanel = _panel.GetComponent <basePanel>(); if (basepanel != null) { basepanel.changeStartPos(_pos.x, _pos.y); } go.transform.localPosition = _pos; return(go); } else { return(null); } }