Пример #1
0
    /// <summary>
    /// 设置IconSprite精灵,使用其他图集
    /// </summary>
    /// <param name="strSprite"></param>
    /// <param name="strAtlas"></param>
    public void SetIconSprite(string strSprite, string strAtlas)
    {
        XUISprite xUISprite = this.GetUIObject("Sprite_Icon") as XUISprite;

        if (null != xUISprite)
        {
            xUISprite.SetSprite(strSprite, strAtlas);
        }
    }
Пример #2
0
 protected override void OnAwake()
 {
     base.OnAwake();
     this.m_XUISprite = base.GetComponent <XUISprite>();
     if (null == this.m_XUISprite)
     {
         Debug.LogError("null == XUISprite, " + base.gameObject.name);
     }
 }
Пример #3
0
    /// <summary>
    /// 根据UI的id设置精灵
    /// </summary>
    /// <param name="strId"></param>
    /// <param name="strSprite"></param>
    public void SetSprite(string strId, string strSprite)
    {
        XUISprite xUISprite = this.GetUIObject(strId) as XUISprite;

        if (null != xUISprite)
        {
            xUISprite.SetSprite(strSprite);
        }
    }
Пример #4
0
    /// <summary>
    /// 根据UI的id设置精灵
    /// </summary>
    /// <param name="strId"></param>
    /// <param name="strSprite"></param>
    public void SetSprite(string strId, string strSprite)
    {
        XUISprite xUISprite = this.GetUIObject(strId) as XUISprite;

        if (null != xUISprite)
        {
            if (!xUISprite.SetSprite(strSprite))
            {
                Debug.LogError("SetSprite Failed");
            }
        }
    }
Пример #5
0
    /// <summary>
    /// 设置IconSprite精灵
    /// </summary>
    /// <param name="strSprite"></param>
    public void SetIconSprite(string strSprite)
    {
        if (null != this.m_uiSpriteIcon)
        {
            this.m_uiSpriteIcon.spriteName = strSprite.Substring(strSprite.LastIndexOf("\\") + 1);
            this.m_uiSpriteIcon.enabled    = true;
        }
        XUISprite xUISprite = this.GetUIObject("Sprite_Icon") as XUISprite;

        if (null != xUISprite)
        {
            xUISprite.SetSprite(strSprite);
        }
    }
Пример #6
0
    protected override void InitWidget()
    {
        this.m_Input_UsernameInput = this.mRoot.FindChild("Login/UserNameInput").GetComponent <UIInput>();
        this.m_Input_PasswordInput = this.mRoot.FindChild("Login/PasswordInput").GetComponent <UIInput>();
        this.m_Button_EnterGame    = this.mRoot.FindChild("Login/LoginButton").GetComponent <UIButton>();

        this.m_Button_ServerListButton = this.mRoot.FindChild("Select/Button/ServerListButton").GetComponent <UIButton>();
        this.m_Button_Select           = this.mRoot.FindChild("Select/Button/SelectButton").GetComponent <UIButton>();
        this.m_Panel_Select            = this.mRoot.FindChild("Select").GetComponent <UIPanel>();
        this.m_List_Dianxin            = this.mRoot.FindChild("Select/ServerList/Table/Dianxin/DianxinGrid").GetComponent <XUIList>();
        this.m_List_Wangtong           = this.mRoot.FindChild("Select/ServerList/Table/Wangtong/WangtongGrid").GetComponent <XUIList>();
        this.m_Sprite_IconBG           = this.mRoot.FindChild("Select/Signal/IconBG").GetComponent <XUISprite>();
        this.m_Sprite_Icon             = this.mRoot.FindChild("Select/Signal/IconAnim").GetComponent <XUISprite>();
        this.m_Sprite_ServerName       = this.mRoot.FindChild("Select/Signal/Name/ServerNameIcon").GetComponent <XUISprite>();
        this.m_List_Dianxin.RegisterListOnClickEventHandler(new ListOnClickEventHandler(this.OnServerListItemClick));
        UIEventListener.Get(this.m_Button_EnterGame.gameObject).onClick       += OnLoginSumbit;
        UIEventListener.Get(this.m_Button_Select.gameObject).onClick          += OnLoginServer;
        UIEventListener.Get(this.m_Button_ServerListButton.gameObject).onClick = (x) => { this.m_bShowServerList = !this.m_bShowServerList; ShowSelectServer(); };
    }
Пример #7
0
    public void AddItem(string text, int value)
    {
        GameObject gameObject = UnityEngine.Object.Instantiate(this.itemtpl.gameObject) as GameObject;

        gameObject.SetActive(true);
        gameObject.name                    = value.ToString();
        gameObject.transform.parent        = this.droplist;
        gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)this.count * this.itemtpl.height));
        gameObject.transform.localScale    = Vector3.one;
        this.count++;
        UILabel component = gameObject.transform.FindChild("ItemText").GetComponent <UILabel>();

        component.text = text;
        this.items.Add(value, text);
        this.itemObjects.Add(value, gameObject);
        XUISprite component2 = gameObject.GetComponent <XUISprite>();

        component2.ID = (ulong)((long)value);
        component2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnItemSelect));
    }
Пример #8
0
 public override void Init()
 {
     base.Init();
     WidgetFactory.FindAllUIObjects(base.transform, this, ref m_dicId2UIObject);
     foreach (var uiObject in this.m_dicId2UIObject.Values)
     {
         uiObject.Parent = this;
         if (!uiObject.IsInited)
         {
             uiObject.Init();
         }
     }
     if (null == this.m_uiSpriteIcon)
     {
         Transform tran = base.transform.FindChild("Sprite_Icon");
         if (tran != null)
         {
             this.m_uiSpriteIcon = tran.GetComponent <UISprite>();
         }
     }
     if (null == this.m_uiTextureIcon)
     {
         Transform tran1 = base.transform.FindChild("Texture_Icon");
         if (tran1 != null)
         {
             this.m_uiTextureIcon = tran1.GetComponent <UITexture>();
         }
     }
     this.m_colldier      = base.GetComponent <Collider>();
     this.m_uiLabels      = base.GetComponentsInChildren <UILabel>();
     this.m_uiToggle      = base.GetComponent <UIToggle>();
     this.m_uiButton      = base.GetComponent <UIButton>();
     this.m_uiSprites     = base.GetComponentsInChildren <UISprite>(true);
     this.m_uiTextures    = base.GetComponentsInChildren <UITexture>(true);
     this.m_uiSpriteFlash = this.GetUIObject("Sprite_Flash") as XUISprite;
     if (this.m_uiToggle != null)
     {
         EventDelegate.Add(this.m_uiToggle.onChange, this.OnSelectStateChange);
     }
     this.Highlight(false);
 }
Пример #9
0
 public override void Init()
 {
     base.Init();
     if (XUITool.Instance != null)
     {
         string uiObjectId = WidgetFactory.GetUIObjectId(this);
         string tip        = XUITool.Instance.GetTip(uiObjectId);
         if (!string.IsNullOrEmpty(tip))
         {
             this.Tip = tip;
         }
     }
     WidgetFactory.FindAllUIObjects(base.transform, this, ref this.m_dicId2UIObject);
     foreach (var current in this.m_dicId2UIObject.Values)
     {
         current.parent    = this;
         current.ParentDlg = this.ParentDlg;
         if (XUITool.Instance != null)
         {
             string uIObjectId2 = WidgetFactory.GetUIObjectId(current);
             string tip2        = XUITool.Instance.GetTip(uIObjectId2);
             if (!string.IsNullOrEmpty(tip2))
             {
                 current.Tip = tip2;
             }
         }
         if (!current.IsInited)
         {
             current.Init();
         }
     }
     if (null == this.m_uiSpriteIcon)
     {
         Transform transform = base.transform.FindChild("Sprite_Icon");
         if (null != transform)
         {
             this.m_uiSpriteIcon = transform.GetComponent <UISprite>();
         }
     }
     if (null == this.m_uiTexture)
     {
         Transform transform2 = base.transform.FindChild("Texture_Icon");
         if (null != transform2)
         {
             this.m_uiTexture = transform2.GetComponent <UITexture>();
         }
     }
     this.m_collider       = base.GetComponent <Collider>();
     this.m_uiLabels       = base.GetComponentsInChildren <UILabel>();
     this.m_uiCheckBox     = base.GetComponent <UIToggle>();
     this.m_uiButton       = base.GetComponent <UIButton>();
     this.m_uiButtonScale  = base.GetComponent <UIButtonScale>();
     this.m_uiPanel        = base.GetComponent <UIPanel>();
     this.m_uiButtonSounds = base.GetComponents <UIPlaySound>();
     this.m_uiSprites      = base.GetComponentsInChildren <UISprite>(true);
     this.m_uiTextures     = base.GetComponentsInChildren <UITexture>(true);
     this.m_dicInitColorLabel.Clear();
     //所有label的颜色都缓存起来
     UILabel[] uiLabels = this.m_uiLabels;
     for (int i = 0; i < uiLabels.Length; i++)
     {
         UILabel uILabel = uiLabels[i];
         if (null != uILabel && !this.m_dicInitColorLabel.ContainsKey(uILabel))
         {
             this.m_dicInitColorLabel.Add(uILabel, uILabel.color);
         }
     }
     //添加checkbox的事件监听,点击选中和不选中
     if (null != this.m_uiCheckBox)
     {
         EventDelegate.Add(this.m_uiCheckBox.onChange, OnSelectStateChange);
     }
     //初始化动画帧精灵
     this.m_xuiSpriteFlash = (this.GetUIObject("Sprite_Flash") as XUISprite);
     this.m_xuiGroupFlash  = (this.GetUIObject("Group_Flash") as XUIGroup);
     //不高亮显示
     this.Highlight(false);
 }
Пример #10
0
 private void OnDragStart()
 {
     if (!base.enabled || this.mTouchID != -2147483648)
     {
         return;
     }
     if (this.restriction != UIDragDropItem.Restriction.None)
     {
         if (this.restriction == UIDragDropItem.Restriction.Horizontal)
         {
             Vector2 totalDelta = UICamera.currentTouch.totalDelta;
             if (Mathf.Abs(totalDelta.x) < Mathf.Abs(totalDelta.y))
             {
                 return;
             }
         }
         else if (this.restriction == UIDragDropItem.Restriction.Vertical)
         {
             Vector2 totalDelta2 = UICamera.currentTouch.totalDelta;
             if (Mathf.Abs(totalDelta2.x) > Mathf.Abs(totalDelta2.y))
             {
                 return;
             }
         }
         else if (this.restriction == UIDragDropItem.Restriction.PressAndHold && this.mPressTime + 1f > RealTime.time)
         {
             return;
         }
     }
     if (this.cloneOnDrag)
     {
         GameObject gameObject = NGUITools.AddChild(base.transform.parent.gameObject, base.gameObject);
         gameObject.transform.localPosition = base.transform.localPosition;
         gameObject.transform.localRotation = base.transform.localRotation;
         gameObject.transform.localScale    = base.transform.localScale;
         XUIDragDropItem xUIDragDropItem  = base.gameObject.GetComponent("XUIDragDropItem") as XUIDragDropItem;
         XUIDragDropItem xUIDragDropItem2 = gameObject.GetComponent("XUIDragDropItem") as XUIDragDropItem;
         if (xUIDragDropItem != null && xUIDragDropItem2 != null)
         {
             xUIDragDropItem2.m_OnFinishHandler = xUIDragDropItem.m_OnFinishHandler;
             xUIDragDropItem2.m_OnStartHandler  = xUIDragDropItem.m_OnStartHandler;
         }
         XUISprite xUISprite  = base.gameObject.GetComponent("XUISprite") as XUISprite;
         XUISprite xUISprite2 = gameObject.GetComponent("XUISprite") as XUISprite;
         if (xUISprite != null && xUISprite2 != null)
         {
             xUISprite2.ID = xUISprite.ID;
         }
         UIWidget[] componentsInChildren = gameObject.GetComponentsInChildren <UIWidget>();
         UIWidget[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             UIWidget uIWidget = array[i];
             uIWidget.depth += 200;
         }
         UIButtonColor component = gameObject.GetComponent <UIButtonColor>();
         if (component != null)
         {
             component.defaultColor = base.GetComponent <UIButtonColor>().defaultColor;
         }
         UICamera.currentTouch.dragged = gameObject;
         UIDragDropItem component2 = gameObject.GetComponent <UIDragDropItem>();
         component2.Start();
         component2.OnDragDropStart();
     }
     else
     {
         this.OnDragDropStart();
     }
 }