public void Init(string asName, Vector2 avPosition, Vector2 avSize, ButtonFunc aButtonFunc, string asLevel) { sName = asName; vPosition = avPosition; vSize = avSize; BFexecute = aButtonFunc; sLevel = asLevel; }
public Button(String assetName, String buttonText, Rectangle pos, ButtonFunc selectFunc) { text = buttonText; sprite = new Sprite(assetName); onSelect = selectFunc; selected = false; position = pos; fontPosition = new Vector2(pos.X + pos.Width / 2, pos.Y + pos.Height / 2); spriteFont = InsanityGame.GameFonts["fonts/ButtonFont"]; }
public override void OnButtonPress() { if (!_loaded && Product == null && _updaterFinished) { LoadProduct(); } if (Product != null) { ButtonFunc.Invoke(Product, null); } }
public override void OnButtonPress() { if (!loaded && Product == null) { LoadProduct(); } if (Product != null) { ButtonFunc.Invoke(Product, null); } }
public override void OnButtonPress() { if (Plugin == null) { LoadPlugin(); } if (Plugin != null) { ButtonFunc.Invoke(Plugin, null); } }
protected GameObject GenerateMenuButton(int index, string text, ButtonFunc buttonOnClick) { GameObject result = ((GameObject)GameObject.Instantiate(_buttonPrefab, Vector3.zero, Quaternion.identity)); Text menuText; Button menuButton; result.transform.SetParent(canvasTrans); result.transform.localPosition = new Vector3(0, 0 - 50 * index, 0); result.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); menuText = result.transform.GetChild(0).GetComponent <Text>(); menuText.text = text; menuButton = result.transform.GetComponent <Button>(); menuButton.onClick.AddListener(() => buttonOnClick()); return(result); }
public void Init(string szContnet, ButtonFunc pfConfirmFunc, object pParam1, ButtonFunc pfCancleFunc, object pParam2) { m_pfConfirmFunc = pfConfirmFunc; m_pParam1 = pParam1; m_pfCancleFunc = pfCancleFunc; m_pParam2 = pParam2; m_textContent.text = szContnet; if (m_pfConfirmFunc != null) { m_buttonConfirm.onClick.AddListener(delegate() { m_pfConfirmFunc(m_pParam1); Destroy(gameObject); }); } if (m_pfCancleFunc != null) { m_buttonCancle.onClick.AddListener(delegate() { m_pfCancleFunc(m_pParam2); Destroy(gameObject); }); } }
//Feed correct button into Input callback bool ButtonHelper(ButtonID button, ButtonFunc bf) { KeyCode key; switch (button) { case ButtonID.ROLL: key = rollkey; break; case ButtonID.SHOT: key = shootkey; break; case ButtonID.SUBWEAPON: key = subweaponkey; break; case ButtonID.SWITCH_MAIN_LEFT: key = switchWeaponLeftKey; break; case ButtonID.SWITCH_MAIN_RIGHT: key = switchWeaponRightKey; break; case ButtonID.SWITCH_SUB_LEFT: key = switchSubLeftKey; break; case ButtonID.SWITCH_SUB_RIGHT: default: key = switchSubRightKey; break; } return(bf(key)); }
public bool GetButtonUp(ButtonID button) { ButtonFunc callback = (KeyCode x) => { return(Input.GetKeyUp(x)); }; return(ButtonHelper(button, callback)); }
public bool GetButtonDown(ButtonID button) { ButtonFunc callback = (KeyCode x) => { return(Input.GetKeyDown(x)); }; return(ButtonHelper(button, callback, false)); }
//Feed correct button into Input callback bool ButtonHelper(ButtonID button, ButtonFunc bf, bool buttonUp) { KeyCode key; bool result = false; switch (button) { case ButtonID.ROLL: key = roll; result = TriggerHelper(rolltrigger, buttonUp); break; case ButtonID.SHOT: key = shotbutton; result = TriggerHelper(shottrigger, buttonUp); break; case ButtonID.SUBWEAPON: key = subweapon; result = TriggerHelper(subtrigger, buttonUp); break; case ButtonID.SWITCH_MAIN_LEFT: key = switchWeaponLeft; break; case ButtonID.SWITCH_MAIN_RIGHT: key = switchWeaponRight; break; case ButtonID.SWITCH_SUB_LEFT: key = switchSubLeft; break; case ButtonID.SWITCH_SUB_RIGHT: default: key = switchSubRight; break; case ButtonID.LOCK_ON: key = lockon; result = TriggerHelper(locktrigger, buttonUp); break; case ButtonID.CANCEL_LOCK_ON: key = cancelLockOn; result = TriggerHelper(unlockTrigger, buttonUp); break; case ButtonID.WEAPON0: key = weapon0; break; case ButtonID.WEAPON1: key = weapon1; break; case ButtonID.WEAPON2: key = weapon2; break; case ButtonID.WEAPON3: key = weapon3; break; } if (!result) { result = bf(key); } //if the result is still false (i.e. trigger input hasn't been converted to button input), then check key return(result); }
public override void OnButtonPress() => ButtonFunc?.Invoke(Plugin, null);