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

[脚本] 通过导入一个包,可以拖拉控件到窗口上,也成功取到了上面的值,部分代码晒给大家

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

  4. public class Demo : MonoBehaviour {

  5.     private BitTextField _text;
  6.     private BitLabel _result;
  7.     // Use this for initialization
  8.      private void Start () {
  9.         Component[] windows=gameObject.GetComponents(typeof(BitWindow));
  10.         BitWindow window=null;
  11.         for(int i=0;i<windows.Length;i++)
  12.         {
  13.             if(windows[i].name=="calculator")
  14.             {
  15.                 window=(BitWindow)windows[i];
  16.             }
  17.         }   
  18.         if(window==null)
  19.             {
  20.                     Debug.LogError("Main window not found");
  21.                     return;
  22.             }
  23.             _result=window.FindControl<BitLabel>("lbname");
  24.             _text=window.FindControl<BitTextField>("name");
  25.             BitButton b;
  26.             b=window.FindControl<BitButton>("bt1");
  27.             b.MouseClick+=contentClick;
  28.             
  29.             
  30.         
  31.     }
  32.     public void contentClick(object sender , MouseEventArgs e)
  33.             {
  34.                 _result.Content.text=_text.Content.text;
  35.             }
  36.    
  37.     // Update is called once per frame
  38.     public void Update () {
  39.    
  40.     }
  41. }
复制代码
{:2_31:}
发表于 2017-2-18 13:27 | 显示全部楼层
很不错
发表于 2017-2-18 14:17 | 显示全部楼层
楼主是超人
发表于 2017-2-18 14:13 | 显示全部楼层
难得一见的好帖
发表于 2017-2-18 14:03 | 显示全部楼层
很好哦
发表于 2017-2-18 14:03 | 显示全部楼层
LZ真是人才
发表于 2017-3-31 21:35 | 显示全部楼层
很不错
发表于 2017-3-31 22:12 | 显示全部楼层
楼主是超人
发表于 2017-3-31 22:13 | 显示全部楼层
顶顶多好
发表于 2017-3-31 21:48 | 显示全部楼层
难得一见的好帖
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-5-12 22:44 , Processed in 0.101856 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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