找回密码
 立即注册
查看: 4713|回复: 80

[脚本] Unity3D显示/隐藏登录窗口代码

  [复制链接]
发表于 2013-2-27 09:56 | 显示全部楼层 |阅读模式
MainWindow窗体的代码:
  1. using UnityEngine;
  2. using System.Collections;
  3. using Bitverse.Unity.Gui;

  4. public class mainDemo : MonoBehaviour {

  5.     BitWindow mainwin=null;
  6.     BitWindow logwin=null;
  7.     BitWindow regwin=null;
  8.     private BitEditorStage _form;
  9.     // Use this for initialization
  10.     void Start () {
  11.         _form=gameObject.GetComponent<BitEditorStage>();
  12.         Component[] windows = gameObject.GetComponents(typeof(BitWindow));
  13.         //Component[] windows = GameObject.Find("main_win");
  14.         logwin=(BitWindow)GameObject.Find("log").GetComponent(typeof(BitWindow));
  15.         regwin=(BitWindow)GameObject.Find("reg").GetComponent(typeof(BitWindow));
  16.         for(int i=0;i<windows.Length;i++)
  17.         {
  18.             if(windows[i].name=="main_win"){
  19.                     mainwin=(BitWindow)windows[i];
  20.                 }
  21.             if(windows[i].name=="log"){
  22.                     logwin=(BitWindow)windows[i];
  23.                 }
  24.         }
  25.         if(mainwin==null){
  26.                 Debug.LogError("mainwin window not found");
  27.                 return;
  28.             }
  29.         if(logwin==null){
  30.                 Debug.LogError("logwin window not found");
  31.                 return;
  32.             }
  33.         if(regwin==null){
  34.             Debug.LogError("regwin window not found");
  35.             return;
  36.         }
  37.         BitButton b1=mainwin.FindControl<BitButton>("log");
  38.         b1.MouseClick+=hideClick;
  39.         BitButton b2=mainwin.FindControl<BitButton>("reg");
  40.         b2.MouseClick+=hideClickReg;
  41.             
  42.     }
  43.     private void hideClick(object sender,MouseEventArgs e)
  44.     {
  45.         logwin.Visible=true;
  46.     }
  47.     private void hideClickReg(object sender,MouseEventArgs e)
  48.     {
  49.         regwin.Visible=true;
  50.         
  51.         //regwin.Visible=true;
  52.     }
  53.    
  54.     // Update is called once per frame
  55.     void Update () {
  56.         
  57.     }
  58. }
复制代码
LoginWindow窗体代码:
  1. using UnityEngine;
  2. using System.Collections;
  3. using Bitverse.Unity.Gui;

  4. public class logDemo : MonoBehaviour {

  5.     BitWindow logwin=null;
  6.    
  7.     void Awake(){
  8.         logwin=(BitWindow)GameObject.Find("log").GetComponent(typeof(BitWindow));
  9.         logwin.Visible=false;
  10.     }
  11.    
  12.     // Use this for initialization
  13.     void Start () {
  14.         
  15.         //logwin=(BitWindow)gameObject.GetComponent(typeof(BitWindow));
  16.         
  17.         
  18.         if(logwin==null){
  19.                 Debug.LogError("logwin window not found");
  20.                 return;
  21.             }
  22.         BitButton b1=logwin.FindControl<BitButton>("btexit");
  23.         b1.MouseClick+=hideClick;
  24.         
  25.     }
  26.     private void hideClick(object sender,MouseEventArgs e)
  27.     {
  28.         logwin.Visible=false;
  29.     }
  30.    
  31.     // Update is called once per frame
  32.     void Update () {
  33.         
  34.     }
  35. }
复制代码

评分

参与人数 1 +1 收起 理由
cxbsr + 1 赞一个!

查看全部评分

发表于 2013-2-28 16:44 | 显示全部楼层
这个帖子不错,大家快来顶起来!
发表于 2013-3-4 10:40 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2013-6-3 14:20 | 显示全部楼层

膜拜中。。。。{:soso__7524161091986203637_5:}
发表于 2013-12-10 10:41 | 显示全部楼层
膜拜中。。。。
发表于 2014-4-20 09:25 | 显示全部楼层
谢谢
下载看看
发表于 2017-2-13 12:10 | 显示全部楼层
很不错
发表于 2017-2-13 12:11 | 显示全部楼层
楼主是超人
发表于 2017-2-13 13:01 | 显示全部楼层
好帖就是要顶
发表于 2017-2-13 12:14 | 显示全部楼层
说的非常好
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-3 14:22 , Processed in 0.278809 second(s), 26 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表