示例#1
0
 void SetupButtons()
 {
     if (this.buttons == null)
     {
         EntityHUDData.Button[] array = this._data.GetButtons();
         this.buttons         = new List <EntityHUD.Button>(array.Length);
         this.buttonListeners = new List <MappedInput.ButtonEventListener>(array.Length);
         for (int i = 0; i < array.Length; i++)
         {
             EntityHUDData.Button button = array[i];
             EntityHUD.Button     nBtn   = new EntityHUD.Button(button);
             this.buttons.Add(nBtn);
             if (nBtn.button != null)
             {
                 this.ownedObjects.Add(nBtn.button.gameObject);
                 GuiClickable componentInChildren = nBtn.button.gameObject.GetComponentInChildren <GuiClickable>();
                 if (componentInChildren != null)
                 {
                     GuiClickableWheel guiClickableWheel = componentInChildren as GuiClickableWheel;
                     if (guiClickableWheel != null)
                     {
                         guiClickableWheel.onclick = delegate(object b)
                         {
                             this.PressedWheel();
                         };
                         guiClickableWheel.ondir = delegate(Vector2 d)
                         {
                             this.UpdateWheel(d);
                         };
                         guiClickableWheel.onrelease = delegate(object b)
                         {
                             this.ReleasedWheel();
                         };
                     }
                     else
                     {
                         componentInChildren.onclick = delegate(object b)
                         {
                             this.PressedButton(nBtn, null);
                         };
                     }
                 }
             }
             if (button.hotkey != null)
             {
                 this.buttonListeners.Add(this._input.RegisterButtonDown(button.hotkey, delegate(InputButton b)
                 {
                     this.PressedButton(nBtn, null);
                 }, -1));
             }
         }
     }
     if (this.mouseTag == null && PlatformInfo.Current.AllowMouseInput)
     {
         this.mouseTag = PrioMouseHandler.GetHandler(this._input).GetListener(2, new PrioMouseHandler.MouseDownFunc(this.MouseDown), new PrioMouseHandler.MouseMoveFunc(this.MouseMove), new PrioMouseHandler.MouseUpFunc(this.MouseUp));
     }
 }
示例#2
0
 public Button(EntityHUDData.Button button)
 {
     this.hotkey = button.hotkey;
     if (button.buttonPrefab != null)
     {
         this.button = OverlayWindow.GetPooledWindow <OverlayWindow>(button.buttonPrefab);
     }
     this.action = button.buttonAction;
     this.toggle = button.toggle;
 }