------------------------------------------------------------------------------------1----------------------------------------------------------------------------------------------------------------改变先后渲染顺序
Canvas c; GameObject b,a; ccan.sortingOrder = 2;//Canvas之间用sortingOrder改变层级 b.transform.SetSiblingIndex(0);//Canvas内部用siblingIndex改变层级 a.transform.SetSiblingIndex(1);
--------------------------------------------------------------------------------------------2------------------------------------------------------------------------------------------------------------------动态的指定按钮点击触发的事件
void Start () { _btn = GameObject.Find("Btn").GetComponent<Button>(); _btn.onClick.AddListener(one); _btn.onClick.AddListener(delegate() { two("叶惠美", "七里香");}); _btn.onClick.AddListener(delegate() { one(); two("十一月的肖邦", "依然范特西~"); three("惊叹号", "哎呦不错喔"); }); ////-----------移除 //_btn.onClick.RemoveAllListeners(); //_btn.onClick.RemoveListener(one); } void one() { Debug.Log("范特西"); } void two(string str1,string str2) { Debug.Log(str1+","+str2); } void three(string str1,string str2) { Debug.Log(str1+","+str2); }
--------------------------------------------------------------------3----------------------------------------------------------------------------------------------------------------------屏幕自适应
1,Canvas Render Mode 设置成screen space-camera,
Ui Scale Mode 设置成Scale With Screen Size,
Screen Math Mode 设置成 Match with Width or Height,
Math设置成0.5 ( 0-1分别代表根据谁适应 )
2,建立Panel,其下建button等控件。
选中Button那个类似九宫格的小方框,Ctrl+某一位置选定向哪个边适应,(Alt+某一位置选定控件在哪个位置)