コード例 #1
0
                } // end UISelectRolePanel

                public void DoBeforeEntering()
                {
                    gameObject = ObjectTool.InstantiateGo("SelectRolePanelUI", ResourcesTool.LoadPrefabUI(id),
                                                          SceneManager.mainCanvas.rectTransform);
                    rectTransform           = gameObject.GetComponent <RectTransform>();
                    rectTransform.sizeDelta = SceneManager.mainCanvas.sizeDelta;
                    roleindex       = 0;
                    createIndex     = -1;
                    selectedindex   = -1;
                    roleDict        = new Dictionary <int, string[]>();
                    t_roleName      = rectTransform.Find("RoleName").GetComponent <Text>();
                    t_roleName.text = "";
                    display         = rectTransform.Find("DisplayRaw").gameObject.AddComponent <UIDisplayRaw>();
                    string prefix = "RoleList/Role_";

                    for (int i = 0; i < 3; i++)
                    {
                        int index = i;
                        roleDict.Add(index, SqliteManager.GetRoleInfoWithID(GameManager.playerInfo.username, index));
                        rectTransform.Find(prefix + i).gameObject.AddComponent <UIButtonNormal>().AddListener(delegate() { OnSwitchRole(index); });
                        if (null != roleDict[index])
                        {
                            rectTransform.Find(prefix + i + "/Text").GetComponent <Text>().text = roleDict[index][0];
                        }
                        // end if
                    } // end for
                    rectTransform.Find("DeleteRoleBtn").gameObject.AddComponent <UIButtonNormal>().AddListener(OnClickDeleteRoleBtn);
                    rectTransform.Find("StartGameBtn").gameObject.AddComponent <UIButtonNormal>().AddListener(OnClickStartGameBtn);
                    InitialSwitchRole();
                } // end DoBeforeEntering