纳金网
标题: 安卓手机上加载预制件,提示框OK,Label不显示?why? [打印本页]
作者: 猪八设计 时间: 2013-10-3 09:40
标题: 安卓手机上加载预制件,提示框OK,Label不显示?why?
转载请教:
在安卓手机上加载了一个提示框的预制件,提示框出来了,可是上面的Label不显示,求解。跪求:
贴下我的代码,求大神们帮我看一下:
- private static GameObject informationPanelPrefab; //提示面板预制件
- private static GameObject tishiPanel; //提示面板
- void Start()
- {
- informationPanelPrefab = (GameObject)Resources.Load("InformationPanelPrefab", typeof(GameObject));
- //informationPanelPrefab = (GameObject)AssetBundle.DontDestroyOnLoad("Assets/AllPrefab/NGUIPrefab/InformationPanelPrefab.prefab");
- }
- void Update() { }
- public static void getInformationPanel(Transform parentTransform, string infor)
- {
- if (tishiPanel == null)
- {
- tishiPanel = (GameObject)GameObject.Instantiate(informationPanelPrefab);
- tishiPanel.AddComponent<UIStretch>();
- tishiPanel.transform.parent = parentTransform;
- tishiPanel.transform.localPosition = new Vector3(0, 0, -5);
- tishiPanel.transform.localScale = new Vector3(1, 1, 1);
- UILabel inforLabel = tishiPanel.gameObject.GetComponentInChildren<UILabel>();
- inforLabel.text = infor;
- Destroy(tishiPanel.gameObject, 2); //设置2秒后删除
- }
- }
复制代码下面是调用这个文件的代码:
- InformationPanelCS.getInformationPanel(panel.transform, "用户名或密码不能为空!请重新输入!");
复制代码