Пример #1
0
        // Token: 0x06000006 RID: 6 RVA: 0x000020F8 File Offset: 0x000002F8
        public static GameObject Add(string name, string label, byte[] pngData, Action <GameObject> action)
        {
            GameObject goButton = null;

            if (Buttons.Contains(name))
            {
                Buttons.Remove(name);
            }
            if (action == null)
            {
                return(goButton);
            }
            try
            {
                goButton = NGUITools.AddChild(Buttons.Grid, UTY.GetChildObject(Buttons.Grid, "Config", true));
                if (name != null)
                {
                    goButton.name = name;
                }
                EventDelegate.Set(goButton.GetComponent <UIButton>().onClick, delegate()
                {
                    action(goButton);
                });
                UIEventTrigger component = goButton.GetComponent <UIEventTrigger>();
                EventDelegate.Add(component.onHoverOut, delegate()
                {
                    Buttons.SysShortcut.VisibleExplanation(null, false);
                });
                EventDelegate.Add(component.onDragStart, delegate()
                {
                    Buttons.SysShortcut.VisibleExplanation(null, false);
                });
                Buttons.SetText(goButton, label);
                if (pngData == null)
                {
                    pngData = DefaultIcon.Png;
                }
                UISprite component2 = goButton.GetComponent <UISprite>();
                component2.type       = UIBasicSprite.Type.Filled;
                component2.fillAmount = 0f;
                Texture2D texture2D = new Texture2D(1, 1);
                texture2D.LoadImage(pngData);
                UITexture uitexture = NGUITools.AddWidget <UITexture>(goButton);
                uitexture.material             = new Material(uitexture.shader);
                uitexture.material.mainTexture = texture2D;
                uitexture.MakePixelPerfect();
                Buttons.Reposition();
            }
            catch
            {
                if (goButton != null)
                {
                    NGUITools.Destroy(goButton);
                    goButton = null;
                }
                throw;
            }
            return(goButton);
        }
Пример #2
0
 public static bool Contains(GameObject go)
 {
     return(Buttons.Contains(go.name));
 }