public void Show(string title, string content, UnityEngine.Events.UnityAction confirmCallback = null, UnityEngine.Events.UnityAction cancelCallback = null) { base.Show(title, content, confirmCallback); _cancelCallback = cancelCallback; _buttonCancel.onClick.AddListener(DoCancelCallBack); }
// Use this for initialization void Start(){ NetworkManagerHUD h = GameObject.Find("Network Control").GetComponent<NetworkManagerHUD>(); UnityEngine.Events.UnityAction<bool> action = new UnityEngine.Events.UnityAction<bool>((bool arg0) => h.enabled = !h.enabled); GetComponent<Toggle>().onValueChanged.AddListener(action); NetworkDiscovery d = GameObject.Find("Network Control").GetComponent<NetworkDiscovery>(); action = new UnityEngine.Events.UnityAction<bool>((bool arg0) => d.enabled = !d.enabled); GetComponent<Toggle>().onValueChanged.AddListener(action); }
void OnEnable() { // Find all the btns in the scene and add listeners to each btns = FindObjectsOfType<Button>(); action = () => {HandleOnBtnClick();}; foreach (Button btn in btns) { AddListener(btn); } }
private EventTrigger.Entry SetupTriggerEntry(){ UnityEngine.Events.UnityAction<BaseEventData> call = new UnityEngine.Events.UnityAction<BaseEventData>(OnTowerButton); EventTriggerType eventID=EventTriggerType.PointerClick; #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY if(UI.UseDragNDrop()) eventID=EventTriggerType.PointerDown; #endif EventTrigger.Entry entry=new EventTrigger.Entry(); entry.eventID = eventID; entry.callback = new EventTrigger.TriggerEvent(); entry.callback.AddListener(call); return entry; }
/// <summary> /// Initial setup. /// </summary> void Start() { if (this.portInputField == null) { Debug.LogError("SetupGameMenuActions.portInputField cannot be null."); } if (this.lobbyPasswordInputField == null) { Debug.LogError("SetupGameMenuActions.lobbyPasswordInputField cannot be null."); } if (this.screenNameInputField == null) { Debug.LogError("SetupGameMenuActions.screenNameInputField cannot be null."); } if (this.launchButton == null) { Debug.LogError("SetupGameMenuActions.launchButton cannot be null."); } // Setup input validation. Deactivate launch button if the input values are bad. var validateAction = new UnityEngine.Events.UnityAction<string>((newValue) => { this.ValidateInputs(); }); this.portInputField.onValueChange.AddListener(validateAction); this.lobbyPasswordInputField.onValueChange.AddListener(validateAction); this.screenNameInputField.onValueChange.AddListener(validateAction); // Add click listener for the launch button. // Animations to waiting scene are done in the editor so we don't have to do lookups. // We could do this in the editor but we scripted everything else. // Might as well do it here too. this.launchButton.onClick.AddListener(new UnityEngine.Events.UnityAction(() => { GameManager.instance.CurrentUserName = this.screenNameInputField.text; GameManager.instance.gameMode = new TeamDeathmatchMode(); ServerSideData.Password = this.lobbyPasswordInputField.text; Cursor.visible = false; if (BoltNetwork.isRunning && BoltNetwork.isClient) { BoltLauncher.Shutdown(); } // We validate this on edit, we shouldn't need to again. BoltLauncher.StartServer(int.Parse(this.portInputField.text)); })); }
private EventTrigger.Entry SetupTriggerEntry(bool requireTargetSelection){ UnityEngine.Events.UnityAction<BaseEventData> call = new UnityEngine.Events.UnityAction<BaseEventData>(OnAbilityButton); EventTriggerType eventID=EventTriggerType.PointerClick; #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY if(requireTargetSelection) eventID=EventTriggerType.PointerDown; #endif EventTrigger.Entry entry=new EventTrigger.Entry(); entry.eventID = eventID; entry.callback = new EventTrigger.TriggerEvent(); entry.callback.AddListener(call); return entry; }
void ActionSelect() { if (this.tag == "Play") { action =()=>{playButton();}; return; } if (this.tag == "Restart") { action =()=>{restartButton();}; return; } if (this.tag == "ExitButton") { action =()=>{exitButton();}; return; } }
public void SetOnTouchUp(string newNote) { if (newNote != null) { if (currentOnTouchUpAction != null) { button.onClick.RemoveListener(currentOnTouchUpAction); } this.onTouchUp = newNote; currentOnTouchUpAction = () => { NotificationCenter.postNotification (Scope (), this.onTouchUp, NotificationCenter.Args("sender", this)); }; button.onClick.AddListener(currentOnTouchUpAction); } }
// Use this for initialization void Start() { RectTransform rt; TextAsset textAsset = (TextAsset) Resources.Load("skill-list"); if (!textAsset) Debug.Log("failed to load xml resource"); var doc = new XmlDocument(); doc.LoadXml (textAsset.text); SkList = new Dictionary<string, SkillDef> (); XmlNodeList root = doc.SelectNodes ("skills/skill"); string id; //for parsing foreach (XmlNode node in root) { id = node.Attributes.GetNamedItem("id").Value; SkList[id] = new SkillDef(); SkList[id].name = node.Attributes.GetNamedItem("name").Value; SkList[id].desc = node.Attributes.GetNamedItem("description").Value; }//foreach node skills = new List<GameObject>(); int i = 0; foreach (KeyValuePair<string, SkillDef> pair in SkList) { var skill = Instantiate (elem); skill.GetComponentInChildren<Text> ().text = pair.Value.name; rt = skill.GetComponent<RectTransform> (); rt.SetParent (panel.transform); var evt = skill.GetComponent<EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback = new EventTrigger.TriggerEvent(); UnityEngine.Events.UnityAction<BaseEventData> callback = new UnityEngine.Events.UnityAction<BaseEventData>(elementClick); entry.callback.AddListener(callback); evt.triggers.Add(entry); skills.Add(skill); } /*skills [1] = Instantiate (elem); skills [1].GetComponentInChildren<Text> ().text = "Dodge"; rt = skills[1].GetComponent<RectTransform>(); rt.SetParent(panel.transform);*/ }
public void Show(string title, string inputHint, string inputPlaceHolder, string inputContent, InputField.ContentType contentType, UnityEngine.Events.UnityAction<string> confirmCallback, UnityEngine.Events.UnityAction cancelCallback) { gameObject.SetActive(true); UIManager.GetInstance().SetSiblingToTop(gameObject); if (title != null) { _labelTitle.text = title; } if (inputHint != null) { _labelInputHint.text = inputHint; } if (inputPlaceHolder != null) { _inputContent.placeholder.GetComponent<Text>().text = inputPlaceHolder; } if (inputContent != null) { _inputContent.text = inputContent; } _inputContent.contentType = contentType; _confirmCallback = confirmCallback; _buttonConfirm.onClick.AddListener(OnClickConfirmButton); if (cancelCallback != null) { _buttonCancel.onClick.AddListener(cancelCallback); } _buttonCancel.onClick.AddListener(Hide); BeginEnterTween(); }
public override void gaxb_init() { base.gaxb_init (); if (title == null) { gameObject.name = "<ImageButton/>"; } button = gameObject.AddComponent<Button> (); ColorBlock colors = button.colors; colors.fadeDuration = 0; button.colors = colors; if (pressedResourcePath != null || highlightedResourcePath != null || disabledResourcePath != null) { button.transition = Selectable.Transition.SpriteSwap; SpriteState states = button.spriteState; if (pressedResourcePath != null) { states.pressedSprite = PlanetUnityResourceCache.GetSprite (pressedResourcePath); } if (highlightedResourcePath != null) { states.highlightedSprite = PlanetUnityResourceCache.GetSprite (highlightedResourcePath); } if (disabledResourcePath != null) { states.disabledSprite = PlanetUnityResourceCache.GetSprite (disabledResourcePath); } button.spriteState = states; } if (onTouchUp != null) { currentOnTouchUpAction = () => { NotificationCenter.postNotification (Scope (), this.onTouchUp, NotificationCenter.Args("sender", this)); }; button.onClick.AddListener(currentOnTouchUpAction); } }
void ActionSelect() { if (this.tag == "Play") { action =()=>{playButton();}; return; } if (this.tag == "Continue") { action =()=>{continueButton();}; return; } if (this.tag == "ExitButton") { action =()=>{exitButton();}; return; } if (this.tag == "Restart") { action =()=>{restartButton();}; return; } if(this.tag == "MainMenu"){ action =()=>{mainMenuButton();}; } }
public void Show(string title, string content, UnityEngine.Events.UnityAction confirmCallback = null) { gameObject.SetActive(true); UIManager.GetInstance().SetSiblingToTop(gameObject); if (title != null) { _labelTitle.text = title; } if (content != null) { _labelContent.text = content; } _confirmCallback = confirmCallback; _buttonConfirm.onClick.AddListener(DoConfirmCallBack); BeginEnterTween(); }
public override void gaxb_init() { base.gaxb_init (); if (title == null) { gameObject.name = "<TextButton/>"; } button = gameObject.AddComponent<Button> (); ColorBlock colors = button.colors; colors.fadeDuration = 0; button.colors = colors; if (onTouchUp != null) { currentOnTouchUpAction = () => { NotificationCenter.postNotification (Scope (), this.onTouchUp, NotificationCenter.Args("sender", this)); }; button.onClick.AddListener(currentOnTouchUpAction); } }
static internal int checkDelegate(IntPtr l, int p, out UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> ua) { int op = extractFunction(l, p); if (LuaDLL.lua_isnil(l, p)) { ua = null; return(op); } else if (LuaDLL.lua_isuserdata(l, p) == 1) { ua = (UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData>)checkObj(l, p); return(op); } LuaDelegate ld; checkType(l, -1, out ld); if (ld.d != null) { ua = (UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData>)ld.d; return(op); } LuaDLL.lua_pop(l, 1); l = LuaState.get(l).L; ua = (UnityEngine.EventSystems.BaseEventData a1) => { int error = pushTry(l); pushValue(l, a1); ld.pcall(1, error); LuaDLL.lua_settop(l, error - 1); }; ld.d = ua; return(op); }
static int _m_UnBind_xlua_st_(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); if (gen_param_count == 1 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING)) { string _type = LuaAPI.lua_tostring(L, 1); GlobalEventSystem.UnBind(_type); return(0); } if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && translator.Assignable <UnityEngine.Events.UnityAction>(L, 2)) { string _type = LuaAPI.lua_tostring(L, 1); UnityEngine.Events.UnityAction _call = translator.GetDelegate <UnityEngine.Events.UnityAction>(L, 2); GlobalEventSystem.UnBind(_type, _call); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to GlobalEventSystem.UnBind!")); }
public bool AddSubButton(string name, UnityEngine.Events.UnityAction l) { if (m_ButtonCount >= m_ContextRoot.childCount) { return(false); } ++m_ButtonCount; Transform child = m_ContextRoot.GetChild(m_ContextRoot.childCount - m_ButtonCount); Text text = UIFinder.Find <Text>(child, "Text"); text.text = name; Button button = child.GetComponent <Button>(); button.onClick.RemoveAllListeners(); if (l != null) { button.onClick.AddListener(l); } return(true); }
public vIKAjustSelector(string weaponCategory, UnityEngine.Events.UnityAction <vWeaponIKAdjust> onSelect, GUISkin skin, vWeaponIKAdjust selected = null) { this.weaponCategory = weaponCategory; this.onSelect = onSelect; this.skin = skin; selectorStyle = new GUIStyle(skin.button); selectorStyle.border = new RectOffset(1, 1, 1, 1); selectorStyle.margin = new RectOffset(0, 0, 0, 0); selectorStyle.padding = new RectOffset(0, 0, 0, 0); selectorStyle.overflow = new RectOffset(0, 0, 0, 0); selectorStyle.alignment = TextAnchor.UpperCenter; selectorStyle.fontSize = 12; selectorStyle.clipping = TextClipping.Clip; selectorStyle.wordWrap = true; if (selected != null) { this.selected = selected; canSelectNull = false; } else { canSelectNull = true; } }
static int _m_SetLuaFunc(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); XLuaFramework.CSLuaBridge gen_to_be_invoked = (XLuaFramework.CSLuaBridge)translator.FastGetCSObj(L, 1); { int _funcID = LuaAPI.xlua_tointeger(L, 2); UnityEngine.Events.UnityAction _func = translator.GetDelegate <UnityEngine.Events.UnityAction>(L, 3); gen_to_be_invoked.SetLuaFunc(_funcID, _func); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
protected Button GetViewElement_Button(string name, UnityEngine.Events.UnityAction callback) { GameObject obj = GetViewElement(name); if (!obj) { UtilityHelper.LogError(string.Format("Get button {0} failed.", name)); return(null); } Button button = obj.GetComponent <Button>(); if (!button) { UtilityHelper.LogError(string.Format("Get button {0} failed.No button component.", name)); return(null); } //显示按钮 obj.SetActive(true); //移除按钮的点击 button.onClick.RemoveAllListeners(); //注册点击事件 button.onClick.AddListener(callback); return(button); }
public void Initialize(UnityEngine.Events.UnityAction Repaint) { ShowProductInfo = new AnimBool(true, Repaint); }
public ProductInfo(UnityEngine.Events.UnityAction Repaint) { Initialize(Repaint); }
public void CreateServerButton(string text, UnityEngine.Events.UnityAction clickEvent, UnityEngine.Events.UnityAction deleteEvent) { GameObject multiplayerButtonInst = Instantiate(multiplayerButton); multiplayerButtonInst.transform.Find("NewGameButton/Text").GetComponent <Text>().text = text; Button multiplayerButtonButton = multiplayerButtonInst.transform.Find("NewGameButton").GetComponent <Button>(); multiplayerButtonButton.onClick = new Button.ButtonClickedEvent(); multiplayerButtonButton.onClick.AddListener(clickEvent); multiplayerButtonInst.transform.SetParent(savedGameAreaContent, false); GameObject delete = Instantiate(savedGamesRef.GetComponent <MainMenuLoadPanel>().saveInstance.GetComponent <MainMenuLoadButton>().deleteButton); Button deleteButtonButton = delete.GetComponent <Button>(); deleteButtonButton.onClick = new Button.ButtonClickedEvent(); deleteButtonButton.onClick.AddListener(deleteEvent); delete.transform.SetParent(multiplayerButtonInst.transform, false); }
public void deregisterUpdateAction(UnityEngine.Events.UnityAction action) { PreciseManeuverConfig.Instance.removeListener(action); }
public void LoadActionButtons() { GameObject actionPanel = GameObject.Find("HUD/actions"); if (!actionPanel) return; //IGameEntity entity = gameObject.GetComponent<IGameEntity>(); var rectTransform = actionPanel.GetComponent<RectTransform>(); var panelTransform = rectTransform.transform; var size = rectTransform.sizeDelta; var globalScaleXY = new Vector2(rectTransform.lossyScale.x, rectTransform.lossyScale.y); var extents = Vector2.Scale(size, globalScaleXY) / 2.0f; var buttonExtents = new Vector2(extents.x / BUTTON_COLUMNS, extents.y / BUTTON_ROWS); var position = rectTransform.position; var point = new Vector2(position.x - extents.x, position.y + extents.y); for (int i = 0; i < BUTTON_COLUMNS * BUTTON_ROWS; i++) { var buttonCenter = point + buttonExtents * (2 * (i % BUTTON_COLUMNS) + 1); buttonCenter.y = point.y - (buttonExtents.y * (2 * (i / BUTTON_COLUMNS) + 1)); //CreateButton(rectTransform, buttonCenter, buttonExtents, ability, actionMethod, !abilityObj.isActive); var buttonObject = new GameObject("Button " + i); buttonObject.tag = "ActionButton"; buttonObject.layer = 5; // UI Layer var image = buttonObject.AddComponent<Image>(); image.tag = "ActionButton"; //image.rectTransform.SetParent(panelTransform); image.rectTransform.localScale = panelTransform.localScale; image.rectTransform.sizeDelta = 1.5f * buttonExtents; image.rectTransform.position = buttonCenter; image.enabled = false; //image.rectTransform.position = transform.position; //image.sprite = CreateSprite(ability, image.rectTransform.sizeDelta); //Debug.LogError("Button position: " + center); var button = buttonObject.AddComponent<Button>(); button.targetGraphic = image; button.transform.SetParent(actionPanel.transform); button.interactable = false; var eventTrigger = buttonObject.AddComponent<EventTrigger>(); EventTrigger.Entry enterEntry = new EventTrigger.Entry(); enterEntry.eventID = EventTriggerType.PointerEnter; enterEntry.callback = new EventTrigger.TriggerEvent(); UnityEngine.Events.UnityAction<BaseEventData> enterCall = new UnityEngine.Events.UnityAction<BaseEventData>(mouseEnter); enterEntry.callback.AddListener(enterCall); eventTrigger.triggers.Add(enterEntry); EventTrigger.Entry exitEntry = new EventTrigger.Entry(); exitEntry.eventID = EventTriggerType.PointerExit; exitEntry.callback = new EventTrigger.TriggerEvent(); UnityEngine.Events.UnityAction<BaseEventData> exitCall = new UnityEngine.Events.UnityAction<BaseEventData>(mouseExit); exitEntry.callback.AddListener(exitCall); eventTrigger.triggers.Add(exitEntry); eventTrigger.enabled = false; //buttonObject.GetComponent<Renderer>().enabled= false; } actionPanel.GetComponent<Image>().enabled = false; }
/// <summary> /// Initial setup. /// </summary> void Start() { if (this.ipInputField == null) { Debug.LogError("SetupGameMenuActions.ipInputField cannot be null."); } if (this.lobbyPasswordInputField == null) { Debug.LogError("SetupGameMenuActions.lobbyPasswordInputField cannot be null."); } if (this.screenNameInputField == null) { Debug.LogError("SetupGameMenuActions.screenNameInputField cannot be null."); } if (this.lobbyButton == null) { Debug.LogError("SetupGameMenuActions.launchButton cannot be null."); } // Setup input validation. Deactivate launch button if the input values are bad. var validateAction = new UnityEngine.Events.UnityAction<string>((newValue) => { this.ValidateInputs(); }); this.ipInputField.onValueChange.AddListener(validateAction); this.lobbyPasswordInputField.onValueChange.AddListener(validateAction); this.screenNameInputField.onValueChange.AddListener(validateAction); // Add click listener for the launch button. // Animations to waiting scene are done in the editor so we don't have to do lookups. // We could do this in the editor but we scripted everything else. // Might as well do it here too. this.lobbyButton.onClick.AddListener(new UnityEngine.Events.UnityAction(() => { GameManager.instance.CurrentUserName = this.screenNameInputField.text; // We validate this on edit, we shouldn't need to again. var addressComponents = this.ipInputField.text.Split(':'); var port = int.Parse(addressComponents[1]); if (BoltNetwork.isRunning && BoltNetwork.isServer) { BoltLauncher.Shutdown(); } connect = true; })); }
public static void CreateModalWindow(string dscrpText, UnityEngine.Events.UnityAction call) { bool myEventSystem = false; if (EventSystem.current == null) { GameObject eventSystem = new GameObject("EventSystem"); eventSystem.AddComponent <TouchInputModule> (); eventSystem.AddComponent <StandaloneInputModule> (); myEventSystem = true; } GameObject canvasGO = new GameObject("ModalWindow"); RectTransform canvasRT = canvasGO.AddComponent <RectTransform> (); Canvas canvasCv = canvasGO.AddComponent <Canvas> (); canvasCv.renderMode = RenderMode.ScreenSpaceOverlay; canvasGO.AddComponent <UnityEngine.UI.CanvasScaler> (); canvasGO.AddComponent <UnityEngine.UI.GraphicRaycaster> (); GameObject bgRaycastBlocker = new GameObject("Panel"); bgRaycastBlocker.transform.SetParent(canvasGO.transform); RectTransform bgRaycastBlockerRT = bgRaycastBlocker.AddComponent <RectTransform> (); bgRaycastBlockerRT.position = canvasRT.transform.position; bgRaycastBlockerRT.sizeDelta = canvasRT.sizeDelta; Image bgRaycastBlockerIm = bgRaycastBlocker.AddComponent <Image> (); bgRaycastBlockerIm.color = new Color(0.2f, 0.2f, 0.2f, 0.3f); GameObject modalWindow = new GameObject("ModalWindow"); modalWindow.transform.SetParent(bgRaycastBlocker.transform); RectTransform modalWindowRT = modalWindow.AddComponent <RectTransform> (); modalWindowRT.localPosition = Vector3.zero; modalWindowRT.sizeDelta = new Vector2(canvasRT.sizeDelta.x / 3, canvasRT.sizeDelta.y / 5); Image modalWindowIm = modalWindow.AddComponent <Image> (); modalWindowIm.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); GameObject titlePanel = new GameObject("TitlePanel"); titlePanel.transform.SetParent(modalWindow.transform); RectTransform titlePanelRT = titlePanel.AddComponent <RectTransform> (); titlePanelRT.anchorMax = new Vector2(1.0f, 1.0f); titlePanelRT.anchorMin = new Vector2(0.0f, 0.7f); titlePanelRT.offsetMax = new Vector2(0, 0); titlePanelRT.offsetMin = new Vector2(0, 0); Image titlePanelIm = titlePanel.AddComponent <Image> (); titlePanelIm.color = new Color(0.7f, 0.7f, 0.7f, 1.0f); GameObject title = new GameObject("Title"); title.transform.SetParent(titlePanel.transform); RectTransform titleRT = title.AddComponent <RectTransform> (); titleRT.anchorMax = new Vector2(1.0f, 1.0f); titleRT.anchorMin = new Vector2(0.0f, 0.0f); titleRT.offsetMax = new Vector2(0, 0); titleRT.offsetMin = new Vector2(0, 0); Text titleText = title.AddComponent <Text> (); titleText.text = "Confirmation"; titleText.color = Color.black; titleText.fontSize = 10; titleText.resizeTextForBestFit = true; titleText.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; titleText.alignment = TextAnchor.MiddleCenter; GameObject description = new GameObject("Desscription"); description.transform.SetParent(modalWindow.transform); RectTransform descriptionRT = description.AddComponent <RectTransform> (); descriptionRT.anchorMax = new Vector2(1.0f, 0.7f); descriptionRT.anchorMin = new Vector2(0.0f, 0.4f); descriptionRT.offsetMax = new Vector2(0, 0); descriptionRT.offsetMin = new Vector2(0, 0); Text descriptionText = description.AddComponent <Text> (); descriptionText.text = dscrpText; descriptionText.color = Color.black; descriptionText.fontSize = 8; descriptionText.resizeTextForBestFit = true; descriptionText.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; descriptionText.alignment = TextAnchor.MiddleCenter; GameObject yes = new GameObject("YesButton"); yes.transform.SetParent(modalWindow.transform); RectTransform yesRT = yes.AddComponent <RectTransform> (); yesRT.anchorMax = new Vector2(1.0f, 0.3f); yesRT.anchorMin = new Vector2(0.51f, 0.0f); yesRT.offsetMax = new Vector2(0, 0); yesRT.offsetMin = new Vector2(0, 0); Image yesIm = yes.AddComponent <Image> (); yesIm.color = new Color(0.6f, 0.6f, 0.6f, 1.0f); Button yesBtn = yes.AddComponent <Button> (); yesBtn.onClick.AddListener(call); yesBtn.onClick.AddListener(() => GameObject.Destroy(canvasGO)); GameObject yesText = new GameObject("YesText"); yesText.transform.SetParent(yes.transform); RectTransform yesTextRT = yesText.AddComponent <RectTransform> (); yesTextRT.anchorMax = new Vector2(1.0f, 1.0f); yesTextRT.anchorMin = new Vector2(0.0f, 0.0f); yesTextRT.offsetMax = new Vector2(0, 0); yesTextRT.offsetMin = new Vector2(0, 0); Text yesTextT = yesText.AddComponent <Text> (); yesTextT.text = "Post"; yesTextT.fontSize = 12; yesTextT.resizeTextForBestFit = true; yesTextT.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; yesTextT.alignment = TextAnchor.MiddleCenter; yesTextT.color = new Color(0.0f, 0.2f, 0.4f, 1.0f); GameObject no = new GameObject("NoButton"); no.transform.SetParent(modalWindow.transform); RectTransform noRT = no.AddComponent <RectTransform> (); noRT.anchorMax = new Vector2(0.49f, 0.3f); noRT.anchorMin = new Vector2(0.0f, 0.0f); noRT.offsetMax = new Vector2(0, 0); noRT.offsetMin = new Vector2(0, 0); Image noIm = no.AddComponent <Image> (); noIm.color = new Color(0.6f, 0.6f, 0.6f, 1.0f); Button noBtn = no.AddComponent <Button> (); noBtn.onClick.AddListener(() => GameObject.Destroy(canvasGO)); if (myEventSystem) { noBtn.onClick.AddListener(() => GameObject.Destroy(EventSystem.current.gameObject)); } GameObject noText = new GameObject("NoText"); noText.transform.SetParent(no.transform); RectTransform noTextRT = noText.AddComponent <RectTransform> (); noTextRT.anchorMax = new Vector2(1.0f, 1.0f); noTextRT.anchorMin = new Vector2(0.0f, 0.0f); noTextRT.offsetMax = new Vector2(0, 0); noTextRT.offsetMin = new Vector2(0, 0); Text noTextT = noText.AddComponent <Text> (); noTextT.text = "Cancel"; noTextT.fontSize = 12; noTextT.resizeTextForBestFit = true; noTextT.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; noTextT.alignment = TextAnchor.MiddleCenter; noTextT.color = new Color(0.0f, 0.2f, 0.4f, 1.0f); }
private GameObject CreateMenuButton(string name, UnityEngine.Events.UnityAction callback, string iconPath, string label) { // clone & modify button if (!HomeSystem.instance.studyActor) { throw new Exception("HomeSystem.instance.studyActor is null"); } var studySkillButton = Common.GetChild(HomeSystem.instance.studyActor, "StudySkill,0"); if (!studySkillButton) { throw new Exception("Failed to get child 'StudySkill,0' from HomeSystem.instance.studyActor"); } var goMenuButton = UnityEngine.Object.Instantiate(studySkillButton, this.menu.transform); goMenuButton.SetActive(true); goMenuButton.name = name; goMenuButton.tag = "Untagged"; var button = goMenuButton.AddComponent <Button>(); button.onClick.AddListener(callback); goMenuButton.AddComponent <PointerClick>(); // modify button background var buttonBack = Common.GetChild(goMenuButton, "StudyEffectBack"); if (!buttonBack) { throw new Exception("Failed to get child 'StudyEffectBack' from 'StudySkill,0'"); } buttonBack.name = "MajordomoMenuButtonBack"; var image = buttonBack.GetComponent <Image>(); image.color = MajordomoWindow.MENU_BTN_BG_COLOR_UNSELECTED; var rectTransform = buttonBack.GetComponent <RectTransform>(); rectTransform.anchorMin = new Vector2(0, 0); rectTransform.anchorMax = new Vector2(1, 0); rectTransform.offsetMin = new Vector2(0, 0); rectTransform.offsetMax = new Vector2(0, 30); // modify button icon var buttonIcon = Common.GetChild(goMenuButton, "StudySkillIcon,0"); if (!buttonIcon) { throw new Exception("Failed to get child 'StudySkillIcon,0' from 'StudySkill,0'"); } buttonIcon.name = "MajordomoMenuButtonIcon"; rectTransform = buttonIcon.GetComponent <RectTransform>(); rectTransform.anchorMin = new Vector2(0, 1); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.offsetMin = new Vector2(25, -80); rectTransform.offsetMax = new Vector2(-25, -20); var buttonIconImage = buttonIcon.GetComponent <Image>(); buttonIconImage.sprite = ResourceLoader.CreateSpriteFromImage(iconPath); if (!buttonIconImage.sprite) { throw new Exception($"Failed to create sprite: {iconPath}"); } // modify button text var buttonText = Common.GetChild(goMenuButton, "StudyEffectText"); if (!buttonText) { throw new Exception("Failed to get child 'StudyEffectText' from 'StudySkill,0'"); } buttonText.name = "MajordomoMenuButtonText"; rectTransform = buttonText.GetComponent <RectTransform>(); rectTransform.anchorMin = new Vector2(0, 0); rectTransform.anchorMax = new Vector2(1, 0); rectTransform.offsetMin = new Vector2(0, 0); rectTransform.offsetMax = new Vector2(0, 30); var text = buttonText.GetComponent <Text>(); if (!text) { throw new Exception("Failed to get Text component from 'StudyEffectText'"); } text.text = label; text.color = MajordomoWindow.MENU_BTN_COLOR_UNSELECTED; TaiwuCommon.SetFont(text); Common.RemoveComponent <SetFont>(buttonText); return(goMenuButton); }
void Awake() { onMissionCreated = null; }
static int _m_RemoveListener(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.Events.UnityEvent <UnityEngine.EventSystems.BaseEventData> __cl_gen_to_be_invoked = (UnityEngine.Events.UnityEvent <UnityEngine.EventSystems.BaseEventData>)translator.FastGetCSObj(L, 1); try { { UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> call = translator.GetDelegate <UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> >(L, 2); __cl_gen_to_be_invoked.RemoveListener(call); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
void SetPageButtons(int pageAmount) { ClearPageButtons(); for (int i = pageAmount - 1; i > -1; i--) { GameObject newPage = (GameObject)GameObject.Instantiate(pageButtonPrefab); newPage.transform.SetParent(pageGridObject.transform); newPage.transform.localScale = new Vector3(1, 1, 1); UnityUIPageInfo pageInfo = newPage.GetComponent<UnityUIPageInfo>(); pageInfo.Init(i, this); OnPageButtonClicked += pageInfo.StoreCurrentPage; Button pageButton = newPage.GetComponent<Button>(); pageButton.onClick.AddListener(OnPageButtonClicked); } }
private GameObject CreateMenuButton(string name, UnityEngine.Events.UnityAction callback, string iconPath, string label) { // clone & modify button Debug.Assert(HomeSystem.instance.studyActor); var studySkillButton = Common.GetChild(HomeSystem.instance.studyActor, "StudySkill,0"); Debug.Assert(studySkillButton); var goMenuButton = UnityEngine.Object.Instantiate(studySkillButton, this.menu.transform); goMenuButton.SetActive(true); goMenuButton.name = name; goMenuButton.tag = "Untagged"; var button = goMenuButton.AddComponent <Button>(); button.onClick.AddListener(callback); goMenuButton.AddComponent <PointerClick>(); // modify button background var buttonBack = Common.GetChild(goMenuButton, "StudyEffectBack"); Debug.Assert(buttonBack); buttonBack.name = "MajordomoMenuButtonBack"; var rectTransform = buttonBack.GetComponent <RectTransform>(); rectTransform.offsetMin = new Vector2(rectTransform.offsetMin.x - 10, rectTransform.offsetMin.y); rectTransform.offsetMax = new Vector2(rectTransform.offsetMax.x + 10, rectTransform.offsetMax.y); // modify button icon var buttonIcon = Common.GetChild(goMenuButton, "StudySkillIcon,0"); Debug.Assert(buttonIcon); buttonIcon.name = "MajordomoMenuButtonIcon"; var buttonIconImage = buttonIcon.GetComponent <Image>(); buttonIconImage.sprite = ResourceLoader.CreateSpriteFromImage(iconPath); if (!buttonIconImage.sprite) { throw new Exception($"Failed to create sprite: {iconPath}"); } // modify button text var buttonText = Common.GetChild(goMenuButton, "StudyEffectText"); Debug.Assert(buttonText); buttonText.name = "MajordomoMenuButtonText"; rectTransform = buttonText.GetComponent <RectTransform>(); rectTransform.offsetMin = new Vector2(rectTransform.offsetMin.x - 10, rectTransform.offsetMin.y); rectTransform.offsetMax = new Vector2(rectTransform.offsetMax.x + 10, rectTransform.offsetMax.y); var text = buttonText.GetComponent <Text>(); Debug.Assert(text); text.text = label; TaiwuCommon.SetFont(text); Common.RemoveComponent <SetFont>(buttonText); return(goMenuButton); }
private IEnumerator FixReviveInteraction(InteractionBase _base, UnityEngine.Events.UnityAction action) { yield return(new WaitForSeconds(0.1f)); _base.OnActivationEvent = action; }
private GameObject CreateButton(string name, string label, UnityEngine.Events.UnityAction callback, GameObject parent) { // clone & modify button // 此函数的触发条件就是 BuildingWindow.instance 存在 var studySkillButton = Common.GetChild(BuildingWindow.instance.studyActor, "StudySkill,0"); if (!studySkillButton) { throw new Exception("Failed to get child 'StudySkill,0' from HomeSystem.instance.studyActor"); } var goButton = UnityEngine.Object.Instantiate(studySkillButton, parent.transform); goButton.SetActive(true); goButton.name = name; goButton.tag = "Untagged"; var button = goButton.AddComponent <Button>(); button.onClick.AddListener(callback); goButton.AddComponent <PointerClick>(); Common.RemoveChildren(goButton, new List <string> { "StudySkillIcon,0" }); // modify button background var buttonBack = Common.GetChild(goButton, "StudyEffectBack"); if (!buttonBack) { throw new Exception("Failed to get child 'StudyEffectBack' from 'StudySkill,0'"); } buttonBack.name = "ButtonBack"; var image = buttonBack.GetComponent <Image>(); image.color = PanelCharts.BTN_BG_COLOR_UNSELECTED; var rectTransform = buttonBack.GetComponent <RectTransform>(); rectTransform.anchorMin = new Vector2(0, 0); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.offsetMin = new Vector2(0, 0); rectTransform.offsetMax = new Vector2(0, 0); // modify button text var buttonText = Common.GetChild(goButton, "StudyEffectText"); if (!buttonText) { throw new Exception("Failed to get child 'StudyEffectText' from 'StudySkill,0'"); } buttonText.name = "ButtonText"; rectTransform = buttonText.GetComponent <RectTransform>(); rectTransform.anchorMin = new Vector2(0, 0); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.offsetMin = new Vector2(0, 0); rectTransform.offsetMax = new Vector2(0, 0); var text = buttonText.GetComponent <Text>(); if (!text) { throw new Exception("Failed to get Text component from 'StudyEffectText'"); } text.text = label; text.color = PanelCharts.BTN_COLOR_UNSELECTED; TaiwuCommon.SetFont(text); Common.RemoveComponent <SetFont>(buttonText); return(goButton); }
/** * Stop the photo capture mode and dispose of the capturing object. * * @param action action that should be invoked after disposing */ public void DisposeActive(UnityEngine.Events.UnityAction action) { this.disposeAction = action; }
void ClearPageButtons() { List<Transform> pageObj = new List<Transform>(); for (int i = 0; i < pageGridObject.transform.childCount; i++) { Transform pageTrans = pageGridObject.transform.GetChild(i); pageObj.Add(pageTrans); UnityUIPageInfo pageInfo = pageTrans.gameObject.GetComponent<UnityUIPageInfo>(); OnPageButtonClicked -= pageInfo.StoreCurrentPage; } pageGridObject.transform.DetachChildren(); foreach (Transform gridItemObj in pageObj) { Destroy(gridItemObj.gameObject); } }
protected void AddNavigation(Button button, UnityEngine.Events.UnityAction navigation) { button.onClick.AddListener(navigation); }
public void registerUpdateAction(UnityEngine.Events.UnityAction action) { PreciseManeuverConfig.Instance.listenToShowChange(action); }
public void AddListener(UnityEngine.Events.UnityAction <int> call) { dropdown.onValueChanged.AddListener(call); }
private void InitEventTrigger() { EventTrigger _eventTrigger = gameObject.AddComponent<EventTrigger>(); EventTrigger.Entry entryS = new EventTrigger.Entry(); entryS.eventID = EventTriggerType.Select; entryS.callback = new EventTrigger.TriggerEvent(); UnityEngine.Events.UnityAction<BaseEventData> callback = new UnityEngine.Events.UnityAction<BaseEventData>(OnSelected); entryS.callback.AddListener (callback); EventTrigger.Entry entryD = new EventTrigger.Entry(); entryD.eventID = EventTriggerType.Deselect; entryD.callback = new EventTrigger.TriggerEvent(); UnityEngine.Events.UnityAction<BaseEventData> callback1 = new UnityEngine.Events.UnityAction<BaseEventData>(OnDeselected); entryD.callback.AddListener (callback1); List<EventTrigger.Entry> delegates = new List<EventTrigger.Entry>(); //TODO Problem for unity compability 500 - 510 delegates.Add (entryS); delegates.Add (entryD); //HACK with new Unity 5.3 //_eventTrigger.delegates = delegates; _eventTrigger.triggers = delegates; }
void OnDestroy() { onMissionCreated = null; }
protected virtual void Startup(RectTransform parent, UnityEngine.Events.UnityAction<object> onEnable) { WaitingLayer.Show(); OnEnable = onEnable; }
private void Button(string label, UnityEngine.Events.UnityAction handler, bool rhs) { CreateButton(label, rhs).button.onClick.AddListener(handler); }
static int _e_sceneLoaded(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode> gen_delegate = translator.GetDelegate <UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode> >(L, 2); if (gen_delegate == null) { return(LuaAPI.luaL_error(L, "#2 need UnityEngine.Events.UnityAction<UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.LoadSceneMode>!")); } if (gen_param_count == 2 && LuaAPI.xlua_is_eq_str(L, 1, "+")) { UnityEngine.SceneManagement.SceneManager.sceneLoaded += gen_delegate; return(0); } if (gen_param_count == 2 && LuaAPI.xlua_is_eq_str(L, 1, "-")) { UnityEngine.SceneManagement.SceneManager.sceneLoaded -= gen_delegate; return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.SceneManagement.SceneManager.sceneLoaded!")); }
internal IEnumerator EquipRoutine(float equipDelay, bool immediate = false, UnityEngine.Events.UnityAction onStart = null, UnityEngine.Events.UnityAction onFinish = null, string itemName = "") { if (debugMode) { Debug.Log("Start Equip: " + itemName); } if (!immediate) { inEquip = true; } while (!IsEquipping && !immediate) { yield return(null); } if (onStart != null) { onStart.Invoke(); } if (!inUnequip && !immediate) // ignore time if inEquip or immediate unequip { var equipTime = equipDelay; while (!immediate && !inUnequip && equipTime > 0f) { equipTime -= vTime.deltaTime; yield return(null); } } inEquip = false; if (onFinish != null) { onFinish.Invoke(); } if (debugMode) { Debug.Log("Finish Equip: " + itemName); } }
static int _e_remove_activeSceneChanged(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); int gen_param_count = LuaAPI.lua_gettop(L); UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.Scene> gen_delegate = translator.GetDelegate <UnityEngine.Events.UnityAction <UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.Scene> >(L, 1); if (gen_delegate == null) { return(LuaAPI.luaL_error(L, "#1 need UnityEngine.Events.UnityAction<UnityEngine.SceneManagement.Scene, UnityEngine.SceneManagement.Scene>!")); } if (gen_param_count == 1) { UnityEngine.SceneManagement.SceneManager.activeSceneChanged -= gen_delegate; return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.SceneManagement.SceneManager.activeSceneChanged!")); }
public void GenerateButton(GameObject prefab, Transform parent, string buttonName, UnityEngine.Events.UnityAction function) { GameObject newButton = Instantiate(prefab); newButton.transform.parent = parent; newButton.GetComponentInChildren <Text>().text = buttonName; newButton.GetComponent <Button>().onClick.AddListener(function); }
public void SubscribeBtnPause(UnityEngine.Events.UnityAction call) { Btn_Pause.onClick.AddListener(call); }
public void OnWorldBuilt(UnityEngine.Events.UnityAction action) { m_onWorldBuilt += action; }
public void SubscribeBtnReset(UnityEngine.Events.UnityAction call) { Btn_Reset.onClick.AddListener(call); }