public void AddButtonEvents(Button thisButton, string name, Item item) { //Add Click Event to Button. thisButton.onClick.AddListener(() => Selected(thisButton, name, item)); //Add OnHover Event to Button. EventTrigger.TriggerEvent triggerOn = new EventTrigger.TriggerEvent(); EventTrigger.Entry entryOn = new EventTrigger.Entry(); triggerOn.AddListener((eventData) => ShowInfoOnHover(name, item)); entryOn.eventID = EventTriggerType.PointerEnter; entryOn.callback = triggerOn; //Add OffHover Event to Button. EventTrigger.TriggerEvent triggerOff = new EventTrigger.TriggerEvent(); EventTrigger.Entry entryOff = new EventTrigger.Entry(); triggerOff.AddListener((eventData) => HideInfoOffHover(name, item)); entryOff.eventID = EventTriggerType.PointerExit; entryOff.callback = triggerOff; //Add Both Events to EventTrigger Component. thisButton.GetComponent<EventTrigger>().enabled = true; thisButton.GetComponent<EventTrigger>().triggers.Add(entryOn); thisButton.GetComponent<EventTrigger>().triggers.Add(entryOff); }
private void AddPointerEnterTrigger(EventTrigger evTrig, EventTriggerType triggerType) { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); AddEventTrigger(evTrig, d => OnPointerEnter(d, evTrig.gameObject), EventTriggerType.PointerEnter); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = triggerEvent, eventID = triggerType }; evTrig.triggers.Add(entry); }
private void AddEventTrigger(EventTrigger evTrig, UnityAction<BaseEventData> action, EventTriggerType triggerType) { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); triggerEvent.AddListener((eventData) => action(eventData)); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = triggerEvent, eventID = triggerType }; evTrig.triggers.Add(entry); }
void AddEventTrgger( UnityAction action, EventTriggerType triggerType ) { EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener( (eventData) => action()); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; eventTrigger.triggers.Add(entry); }
// ------------------ Constants and statics // ------------------ Events // ------------------ Serialized fields and properties // ------------------ Non-serialized fields // ------------------ Methods public static void AddEventTrigger(EventTrigger eventTrigger, UnityAction unityAction, EventTriggerType eventTriggerType) { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); triggerEvent.AddListener((eventData) => unityAction()); // ignore event data EventTrigger.Entry entry = new EventTrigger.Entry() { callback = triggerEvent, eventID = eventTriggerType }; eventTrigger.triggers.Add(entry); }
// Use listener that uses additional argument private void AddEventTrigger(UnityAction<Toggle> action, EventTriggerType triggerType, Toggle toggle) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(toggle)); // pass additonal argument to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.delegates.Add(entry); }
// Use listener that uses the BaseEventData passed to the Trigger private void AddEventTrigger(UnityAction<BaseEventData> action, EventTriggerType triggerType) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(eventData)); // capture and pass the event data to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
private void RegisterEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction <BaseEventData> action) { EventTrigger evnetTrigger = m_Bg.GetComponent <EventTrigger>(); if (evnetTrigger == null) { evnetTrigger = m_Bg.AddComponent <EventTrigger>(); } EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = eventTriggerType; EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); triggerEvent.AddListener(action); entry.callback = triggerEvent; evnetTrigger.triggers.Add(entry); }
public static void SetEventTriggerClick(this EventTrigger trigger, UnityAction <BaseEventData> onClick, IButtonSoundProvider soundProvider) { trigger?.triggers?.Clear(); if (onClick != null) { EventTrigger.TriggerEvent clickEvent = new EventTrigger.TriggerEvent(); clickEvent.AddListener((bed) => { soundProvider?.PlayButton(); onClick?.Invoke(bed); }); trigger?.triggers?.Add(new EventTrigger.Entry { eventID = EventTriggerType.PointerClick, callback = clickEvent }); } }
public static void AddEventTrigger(EventTrigger eventTrigger, UnityAction <System.Object> action, EventTriggerType triggerType, System.Object eventObj) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(eventObj)); // pass additonal argument to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.delegates.Add(entry); }
private void AddEventTrigger(UnityAction<GameObject> action, EventTriggerType triggerType, GameObject go) { EventTrigger eventTrigger = go.GetComponent<EventTrigger>(); if (eventTrigger == null) { eventTrigger = go.AddComponent<EventTrigger>(); eventTrigger.triggers = new System.Collections.Generic.List<EventTrigger.Entry>(); } // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(go)); // capture and pass the event data to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
public static void addEventTrigger(EventTrigger eventTrigger, UnityAction <BaseEventData> action, EventTriggerType triggerType) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener(action); // you can capture and pass the event data to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
public static void AddEventTrigger(EventTrigger eventTrigger, UnityAction action, EventTriggerType triggerType) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action()); // ignore event data // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.delegates.Add(entry); }
// Use listener that uses additional argument private void AddEventTrigger(UnityAction <Toggle> action, EventTriggerType triggerType, Toggle toggle) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(toggle)); // pass additonal argument to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.delegates.Add(entry); }
// Use listener that uses the BaseEventData passed to the Trigger private void AddEventTrigger(UnityAction <BaseEventData> action, EventTriggerType triggerType) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(eventData)); // capture and pass the event data to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.delegates.Add(entry); }
//Setup events listeners; void SetupListeners() { eventTrigger = gameObject.GetComponent <EventTrigger>(); var a = new EventTrigger.TriggerEvent(); a.AddListener(data => { var evData = (PointerEventData)data; data.Use(); isPressed = true; toggle = !toggle; prevDelta = dragInput = evData.position; StartCoroutine("WasClicked"); }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = a, eventID = EventTriggerType.PointerDown }); var b = new EventTrigger.TriggerEvent(); b.AddListener(data => { var evData = (PointerEventData)data; data.Use(); dragInput = evData.position; }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = b, eventID = EventTriggerType.Drag }); var c = new EventTrigger.TriggerEvent(); c.AddListener(data => { touchInput = Vector2.zero; isPressed = false; StartCoroutine("WasReleased"); }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = c, eventID = EventTriggerType.PointerUp }); }
void Awake() { EventTrigger evtrig = gameObject.AddComponent <EventTrigger>(); EventTrigger.TriggerEvent trigev = new EventTrigger.TriggerEvent(); trigev.AddListener((eventData) => Fix(eventData)); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigev, eventID = EventTriggerType.Select }; if (evtrig.triggers == null) { evtrig.triggers = new List <EventTrigger.Entry>(); } evtrig.triggers.Add(entry); }
private void AddEventTrigger(UnityAction action, EventTriggerType triggerType) { if (EventTrigger == null) { return; } EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action()); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; EventTrigger.triggers.Add(entry); }
private void SubscribeToEndDragEvent() { EventTrigger.TriggerEvent triggerEvent = new EventTrigger.TriggerEvent(); EventTriggerType triggerType = EventTriggerType.EndDrag; triggerEvent.AddListener(OnSliderEndDrag); EventTrigger.Entry entryTrigger = new EventTrigger.Entry { callback = triggerEvent, eventID = triggerType }; _minSliderTrigger.triggers.Add(entryTrigger); _maxSliderTrigger.triggers.Add(entryTrigger); }
//Events Initialization For Steering Wheel. void SteeringWheelEventsInit() { eventTrigger = steeringWheelGameObject.GetComponent <EventTrigger>(); var a = new EventTrigger.TriggerEvent(); a.AddListener(data => { var evData = (PointerEventData)data; data.Use(); steeringWheelPressed = true; steeringWheelTouchPos = evData.position; steeringWheelTempAngle = Vector2.Angle(Vector2.up, evData.position - steeringWheelCenter); }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = a, eventID = EventTriggerType.PointerDown }); var b = new EventTrigger.TriggerEvent(); b.AddListener(data => { var evData = (PointerEventData)data; data.Use(); steeringWheelTouchPos = evData.position; }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = b, eventID = EventTriggerType.Drag }); var c = new EventTrigger.TriggerEvent(); c.AddListener(data => { steeringWheelPressed = false; }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = c, eventID = EventTriggerType.EndDrag }); }
/// <summary> /// UI事件添加函数 /// </summary> /// <param name="go"></param> /// <param name="triggerType"></param> /// <param name="func"></param> public static void AddTrigger(GameObject go, EventTriggerType triggerType, LuaFunction func) { EventTrigger evtTrigger = go.GetComponent <EventTrigger>(); if (evtTrigger == null) { evtTrigger = go.AddComponent <EventTrigger>(); } EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener(o => func.Call(o)); evtTrigger.triggers.Add(new EventTrigger.Entry() { eventID = triggerType, callback = trigger, }); }
void Start() { var trigger = eventTriggerGo.GetComponent <EventTrigger>(); var triggerEvent = new EventTrigger.TriggerEvent(); triggerEvent.AddListener((baseData) => { Debug.LogError(baseData.selectedObject.name); }); trigger.triggers = new List <EventTrigger.Entry> { new EventTrigger.Entry { eventID = EventTriggerType.PointerClick, callback = triggerEvent } }; }
public static int constructor(IntPtr l) { int result; try { EventTrigger.TriggerEvent o = new EventTrigger.TriggerEvent(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public void Start() { EventTrigger eventTrigger = gameObject.GetComponent <EventTrigger>(); if (eventTrigger != null && eventTrigger.triggers != null) { EventTrigger.TriggerEvent trigger1 = new EventTrigger.TriggerEvent(); trigger1.AddListener((eventData) => OnTouchDown()); EventTrigger.Entry pointDownEntry = new EventTrigger.Entry() { callback = trigger1, eventID = EventTriggerType.PointerDown }; EventTrigger.TriggerEvent trigger2 = new EventTrigger.TriggerEvent(); trigger2.AddListener((eventData) => OnTouchUp()); EventTrigger.Entry pointUpEntry = new EventTrigger.Entry() { callback = trigger2, eventID = EventTriggerType.PointerUp }; //EventTrigger.TriggerEvent trigger3 = new EventTrigger.TriggerEvent(); //trigger3.AddListener((eventData) => OnTouchClick()); //EventTrigger.Entry pointClickEntry = new EventTrigger.Entry() { callback = trigger3, eventID = EventTriggerType.PointerClick }; EventTrigger.TriggerEvent trigger3 = new EventTrigger.TriggerEvent(); trigger3.AddListener((eventData) => OnTouchEnter()); EventTrigger.Entry pointEnterEntry = new EventTrigger.Entry() { callback = trigger3, eventID = EventTriggerType.PointerEnter }; EventTrigger.TriggerEvent trigger4 = new EventTrigger.TriggerEvent(); trigger4.AddListener((eventData) => OnTouchExit()); EventTrigger.Entry pointExitEntry = new EventTrigger.Entry() { callback = trigger4, eventID = EventTriggerType.PointerExit }; eventTrigger.triggers.Add(pointDownEntry); eventTrigger.triggers.Add(pointUpEntry); //eventTrigger.triggers.Add(pointClickEntry); eventTrigger.triggers.Add(pointEnterEntry); eventTrigger.triggers.Add(pointExitEntry); } }
public override void OnShow(object param) { var arg = (Argument)param; // Show Name of Room NameInput.text = arg.CurrentRoomName ?? ""; // Clear Room List foreach (var room in _roomItems) { GameObject.Destroy(room); } _roomItems.Clear(); // Show Room List var y = 0f; foreach (var roomName in arg.RoomList) { var goItem = UiHelper.AddChild(RoomList.content.gameObject, RoomListTemplate); goItem.GetComponent <Text>().text = roomName; var rt = goItem.GetComponent <RectTransform>(); var posy = rt.localPosition.y - y; rt.localPosition = new Vector3(rt.localPosition.x, posy, rt.localPosition.z); y += rt.rect.height; var localRoomName = roomName; var trigger = new EventTrigger.TriggerEvent(); trigger.AddListener(_ => OnRoomItemClick(localRoomName)); var entry = new EventTrigger.Entry { callback = trigger, eventID = EventTriggerType.PointerClick }; goItem.GetComponent <EventTrigger>().triggers.Add(entry); goItem.SetActive(true); _roomItems.Add(goItem); } RoomList.content.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y); RoomListTemplate.SetActive(false); }
private void stage2() { flee.onClick.RemoveListener(destroyThis); fight.onClick.RemoveListener(stage2); action.onClick.RemoveListener(setInactive); if (controller.enemyPlayer.aliveCats.Count == 1) { destroyThis(); return; } foreach (ExploreCat cat in controller.enemyPlayer.aliveCats) { EventTrigger.TriggerEvent TE = cat.gameObject.GetComponent <EventTrigger>().triggers.Find(x => x.eventID == EventTriggerType.PointerClick).callback; TE.AddListener(stage3); enemyTriggers.Add(TE); } ContinueTutorial(); }
void InitEventsSystem() { // Warning: Be ready to see some extremely boring code here <img class="wp-smiley emoji" draggable="false" alt=":-/" src="https://s1.wp.com/wp-content/mu-plugins/wpcom-smileys/uneasy.svg" style="height: 1em; max-height: 1em;" width="16" height="16"> // You are warned! EventTrigger events = UI_Element.gameObject.GetComponent <EventTrigger>(); if (events == null) { events = UI_Element.gameObject.AddComponent <EventTrigger>(); } if (events.triggers == null) { events.triggers = new System.Collections.Generic.List <EventTrigger.Entry>(); } EventTrigger.Entry entry = new EventTrigger.Entry(); EventTrigger.TriggerEvent callback = new EventTrigger.TriggerEvent(); UnityAction <BaseEventData> functionCall = new UnityAction <BaseEventData>(PressEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerDown; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction <BaseEventData>(DragEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.Drag; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction <BaseEventData>(ReleaseEvent);// callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerUp; entry.callback = callback; events.triggers.Add(entry); }
void InitEventsSystem() { // Warning: Be ready to see some extremely boring code here :-/ // You are warned! EventTrigger events = UI_Element.gameObject.GetComponent <EventTrigger> (); if (events == null) { events = UI_Element.gameObject.AddComponent <EventTrigger> (); } if (events.triggers == null) { events.triggers = new System.Collections.Generic.List <EventTrigger.Entry> (); } EventTrigger.Entry entry = new EventTrigger.Entry(); EventTrigger.TriggerEvent callback = new EventTrigger.TriggerEvent(); UnityAction <BaseEventData> functionCall = new UnityAction <BaseEventData> (PressEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerDown; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction <BaseEventData> (DragEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.Drag; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction <BaseEventData> (ReleaseEvent); // callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerUp; entry.callback = callback; events.triggers.Add(entry); }
public void GenerateSettingsFileButtons() { // we need to clear out the children in the list before we generate new ones for (int i = 0; i < widgetList.transform.childCount; i++) { //widgetList.transform.GetChild(i).gameObject.SetActive(false); Debug.Log("destroying: " + widgetList.transform.GetChild(i).name); Destroy(widgetList.transform.GetChild(i).gameObject); } // we need to clear out the children in the list before we generate new ones for (int i = 0; i < fieldsList.transform.childCount; i++) { fieldsList.transform.GetChild(i).gameObject.SetActive(false); Debug.Log("destroying: " + fieldsList.transform.GetChild(i).name); Destroy(fieldsList.transform.GetChild(i).gameObject); } foreach (string name in loadedFiles) { GameObject newBut = Instantiate(Resources.Load("WidgetSettings/WidgetButton")) as GameObject; newBut.transform.SetParent(widgetList.transform); newBut.GetComponentInChildren <Text>().text = name; // code to add a listener to the button OnClicked() event EventTrigger eTrigger = newBut.GetComponent <EventTrigger>(); EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); // The following line adds the DisplaySettingsFile function as a listener to the EventTrigger on the button we instantiated. trigger.AddListener((eventData) => displaySettingsPanel.SetActive(true)); trigger.AddListener((eventData) => DisplaySettingsFile(newBut)); // The next line adds the entry we created to the Event Trigger of the instantiated button. // The entry consists of two parts, the listener we set up earlier, and the EventTriggerType. // The EventTriggerType tells the EventTrigger when to send out the message that the event has occured. // We use PointerClick so we know when the used has clicked on a button. EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = EventTriggerType.PointerClick }; eTrigger.triggers.Add(entry); } }
// Use this for initialization void Start() { EventTrigger.TriggerEvent hoverEvent = new EventTrigger.TriggerEvent(); hoverEvent.AddListener((BaseEventData unused) => StartHover()); EventTrigger.TriggerEvent unHoverEvent = new EventTrigger.TriggerEvent(); unHoverEvent.AddListener((BaseEventData unused) => UnHover()); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerEnter; entry.callback = hoverEvent; EventTrigger.Entry entry2 = new EventTrigger.Entry(); entry2.eventID = EventTriggerType.PointerExit; entry2.callback = unHoverEvent; EventTrigger trigger = GetComponent <EventTrigger>(); trigger.delegates.Add(entry); trigger.delegates.Add(entry2); }
public static IObservable <BaseEventData> OnEventTriggerdAsObservable(this EventTrigger t, EventTriggerType type) { return(Observable.Create <BaseEventData>(observer => { EventTrigger.TriggerEvent callback = new EventTrigger.TriggerEvent(); callback.AddListener(observer.OnNext); EventTrigger.Entry entry = new EventTrigger.Entry { eventID = type, callback = callback, }; t.triggers.Add(entry); return Disposable.Create(() => t.triggers.Remove(entry)); })); }
public static GameObject AddEventTrigger(this GameObject go, EventTriggerType triggerType, UnityAction <BaseEventData> callback) { var click = new EventTrigger.TriggerEvent(); click.AddListener(callback); var trigger = go.GetComponent <EventTrigger>(); if (!trigger) { trigger = go.AddComponent <EventTrigger>(); } trigger.triggers .Add(new EventTrigger.Entry() { eventID = triggerType, callback = click }); return(go); }
//Setup move event; void SetupListener() { eventTrigger = GetComponent <EventTrigger>(); var ev = new EventTrigger.TriggerEvent(); ev.AddListener(data => { var evData = (PointerEventData)data; data.Use(); movePos = rect.position; movePos.x += evData.delta.x * Time.deltaTime; movePos.y += evData.delta.y * Time.deltaTime; rect.position = GameManager.isGameOver ? rect.position : movePos; }); eventTrigger.triggers.Add(new EventTrigger.Entry { callback = ev, eventID = EventTriggerType.Drag }); }
private void InitEventsSystem() { EventTrigger events = steeringWheelGraphic.gameObject.GetComponent <EventTrigger>(); if (events == null) { events = steeringWheelGraphic.gameObject.AddComponent <EventTrigger>(); } if (events.triggers == null) { events.triggers = new List <EventTrigger.Entry>(); } EventTrigger.Entry entry = new EventTrigger.Entry(); EventTrigger.TriggerEvent callback = new EventTrigger.TriggerEvent(); UnityAction <BaseEventData> functionCall = PressEvent; callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerDown; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = DragEvent; callback.AddListener(functionCall); entry.eventID = EventTriggerType.Drag; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = ReleaseEvent; // callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerUp; entry.callback = callback; events.triggers.Add(entry); }
private void SetAttacks() { foreach (var button in ChoiseButtons) { Destroy(button.gameObject); } ChoiseButtons.Clear(); if (Fighter.Selected != null) { Atributes atributes = Fighter.Selected.Atributes; foreach (Attack attacks in atributes.Feats) { GameObject newButton = GameObject.Instantiate(ButtonPrefab); newButton.transform.SetParent(transform); Button button = newButton.GetComponent <Button>(); button.onClick.AddListener(delegate { SelectedAttack(Fighter.Selected, attacks); }); EventTrigger eventTrigger = newButton.GetComponent <EventTrigger>(); EventTrigger.TriggerEvent enterTrigger = new EventTrigger.TriggerEvent(); EventTrigger.TriggerEvent exitTrigger = new EventTrigger.TriggerEvent(); enterTrigger.AddListener(delegate { PointerEnter(Fighter.Selected, attacks, button.gameObject); }); exitTrigger.AddListener(delegate { PointerExit(); }); EventTrigger.Entry enterEntry = new EventTrigger.Entry() { callback = enterTrigger, eventID = EventTriggerType.PointerEnter }; EventTrigger.Entry exitEntry = new EventTrigger.Entry() { callback = exitTrigger, eventID = EventTriggerType.PointerExit }; eventTrigger.triggers.Add(enterEntry); eventTrigger.triggers.Add(exitEntry); } } }
private void InitEventsSystem() { EventTrigger events = UI_Element.gameObject.GetComponent <EventTrigger>(); if (events == null) { events = UI_Element.gameObject.AddComponent <EventTrigger>(); } if (events.triggers == null) { events.triggers = new System.Collections.Generic.List <EventTrigger.Entry>(); } EventTrigger.Entry entry = new EventTrigger.Entry(); EventTrigger.TriggerEvent callback = new EventTrigger.TriggerEvent(); UnityAction <BaseEventData> functionCall = new UnityAction <BaseEventData>(PressEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerDown; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction <BaseEventData>(DragEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.Drag; entry.callback = callback; events.triggers.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction <BaseEventData>(ReleaseEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerUp; entry.callback = callback; events.triggers.Add(entry); }
protected override void Start() { base.Start(); // if you don't name each button, this may be fail lockFlag = string.Format("{0}.{1}", name, lockFlag); // button scale effect if (scaleEffect) { gameObject.AddComponent <EventToShake>(); } // copy event from other script (because we need to control) if (m_OnClick.GetPersistentEventCount() <= 0) { // copy click event from EventTrigger EventTrigger trg = GetComponent <EventTrigger>(); if (trg && trg.triggers != null) { foreach (EventTrigger.Entry entry in trg.triggers) { if (entry.eventID == EventTriggerType.PointerClick) { m_triggerEvent = entry.callback; entry.callback = new EventTrigger.TriggerEvent(); } } } // copy click event from Button Button but = GetComponent <Button>(); if (but && but.onClick != null) { m_OnClick = but.onClick; but.onClick = new Button.ButtonClickedEvent(); } } // register page page = GetComponentInParent <UIBase>(); }
private void AddEventTrigger(UnityAction <GameObject, PointerEventData> action, EventTriggerType triggerType, GameObject go) { EventTrigger eventTrigger = go.GetComponent <EventTrigger>(); if (eventTrigger == null) { eventTrigger = go.AddComponent <EventTrigger>(); eventTrigger.triggers = new System.Collections.Generic.List <EventTrigger.Entry>(); } // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(go, (PointerEventData)eventData)); // capture and pass the event data to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
void InitEventsSystem() { // Warning: Be ready to see some extremely boring code here :-/ // You are warned! EventTrigger events = UI_Element.gameObject.GetComponent<EventTrigger>(); if (events == null) events = UI_Element.gameObject.AddComponent<EventTrigger>(); if (events.delegates == null) events.delegates = new System.Collections.Generic.List<EventTrigger.Entry>(); EventTrigger.Entry entry = new EventTrigger.Entry(); EventTrigger.TriggerEvent callback = new EventTrigger.TriggerEvent(); UnityAction<BaseEventData> functionCall = new UnityAction<BaseEventData>(PressEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerDown; entry.callback = callback; events.delegates.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction<BaseEventData>(DragEvent); callback.AddListener(functionCall); entry.eventID = EventTriggerType.Drag; entry.callback = callback; events.delegates.Add(entry); entry = new EventTrigger.Entry(); callback = new EventTrigger.TriggerEvent(); functionCall = new UnityAction<BaseEventData>(ReleaseEvent);// callback.AddListener(functionCall); entry.eventID = EventTriggerType.PointerUp; entry.callback = callback; events.delegates.Add(entry); }
public static void Initializ() { Variables.panelConfirmation = GameObject.Find ("PanelConfirmation"); Variables.panelTarget = GameObject.Find ("PanelTarget"); Variables.panelTargetBar = GameObject.Find ("PanelTargetHPBarLine").GetComponent<Image> (); Variables.panelTargetText = GameObject.Find ("PanelTargetText").GetComponent<Text> (); Variables.panelPlayerHPBar = GameObject.Find ("PanelPlayerHPBarLine").GetComponent<Image> (); Variables.panelPlayerHPBarText = GameObject.Find ("PanelPlayerHPBarText").GetComponent<Text> (); Variables.panelPlayerMPBar = GameObject.Find ("PanelPlayerMPBarLine").GetComponent<Image> (); Variables.panelPlayerMPBarText = GameObject.Find ("PanelPlayerMPBarText").GetComponent<Text> (); Variables.panelPlayerEXPBar = GameObject.Find ("PanelPlayerEXPBarLine").GetComponent<Image>(); Variables.panelPlayerEXPBarText = GameObject.Find ("PanelPlayerEXPBarText").GetComponent<Text> (); Variables.panelPlayerLVLText = GameObject.Find ("TextLVL").GetComponent<Text> (); Variables.personList.Add (new Person(GameObject.Find("Player"))); Variables.panelSkills = GameObject.Find ("PanelSkills"); Variables.panelStatus = GameObject.Find ("PanelStatus"); Variables.panelAction = GameObject.Find ("PanelAction"); Variables.panelInventory = GameObject.Find ("PanelInventory"); Variables.panelOption = GameObject.Find ("PanelOption"); Variables.panelSetting = GameObject.Find ("PanelSetting"); Variables.panelResurrection = GameObject.Find ("PanelResurrection"); Variables.dragImageObject = GameObject.Find ("DragImage"); Variables.panelAmount = GameObject.Find ("PanelAmount"); Variables.panelDebug = GameObject.Find ("PanelDebug"); Variables.panelInventoryTransform = Variables.panelInventory.transform; Variables.panelSkillsTransform = Variables.panelSkills.transform; Variables.panelSkillsButtonPanelTransform = Variables.panelSkillsTransform.FindChild ("PanelButton").transform; Variables.panelInventoryButtonPanelTransform = Variables.panelInventoryTransform.FindChild ("PanelButton").transform; Variables.panelStatusTransform = Variables.panelStatus.transform; Variables.panelActionTransform = Variables.panelAction.transform; Variables.panelDebugTransform = Variables.panelDebug.transform; Variables.panelHotkeysTransform = GameObject.Find("PanelHotkeys").transform; Variables.panelSettingTransform = Variables.panelSetting.transform; Variables.panelBuffTransform = GameObject.Find("PanelBuff").transform; Variables.scriptItemValue = GameObject.Find ("ItemValue").GetComponent<ItemValue>(); Variables.scriptMainScript = GameObject.Find ("MainControl").GetComponent<MainScript>(); Variables.scriptSkillValue = GameObject.Find ("SkillValue").GetComponent<SkillValue>(); Variables.scriptButtonValue = GameObject.Find ("ButtonValue").GetComponent<ButtonValue>(); Variables.equipmentImage.Add(GameObject.Find ("WeaponEquipment").GetComponent<Image> ()); Variables.equipmentImage.Add(GameObject.Find ("WeaponEquipment1").GetComponent<Image> ()); Variables.dragImage = Variables.dragImageObject.GetComponent<Image>(); Variables.amountText = GameObject.Find ("InputFieldAmount").GetComponent<InputField> (); Variables.debugInput = GameObject.Find ("InputFieldDebug").GetComponent<InputField> (); Variables.statusValDamage = GameObject.Find ("ValueDamage").GetComponent<Text> (); Variables.statusValMagDamage = GameObject.Find ("ValueMagDamage").GetComponent<Text> (); Variables.statusValResist = GameObject.Find ("ValueResist").GetComponent<Text> (); Variables.statusValMagResist = GameObject.Find ("ValueMagResist").GetComponent<Text> (); Variables.statusValAttackSpeed = GameObject.Find ("ValueAttackSpeed").GetComponent<Text> (); Variables.statusValCastSpeed = GameObject.Find ("ValueCastSpeed").GetComponent<Text> (); Variables.statusValSpeed = GameObject.Find ("ValueSpeed").GetComponent<Text> (); Variables.statusValEvasion = GameObject.Find ("ValueEvasion").GetComponent<Text> (); Variables.statusValCritChance = GameObject.Find ("ValueCritChance").GetComponent<Text> (); Variables.statusValCritRate = GameObject.Find ("ValueCritRate").GetComponent<Text> (); for(int i = 0; i<63; i++){ Variables.inventoryButtonList.Add(-1); Variables.inventoryAmountList.Add(0); Variables.inventoryObjectButtonList.Add(new SkillObjectButton(GameObject.Instantiate( Variables.scriptMainScript.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject)); Variables.inventoryObjectButtonList[i].obj.transform.SetParent(Variables.panelInventoryButtonPanelTransform); int ii = i; Variables.inventoryObjectButtonList[i].button.onClick.AddListener(delegate { Variables.scriptMainScript.Inventory(ii);}); EventTrigger.TriggerEvent t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptMainScript.BeginDragInventory(ii);}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add(new EventTrigger.Entry{callback = t , eventID = EventTriggerType.BeginDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptMainScript.EndDrag();}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.EndDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptMainScript.EnterInventoryBut(ii);}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerEnter}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptMainScript.ExitInventoryBut();}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerExit}); } for (int i=0; i< 12; i++) { Variables.panelButtonList.Add (0); } for (int i=0; i< 10; i++) { //Variables.skillCooldownList.Add (0); Variables.buffList.Add (new BuffClass ()); Variables.debuffList.Add (new BuffClass ()); } Transform vGm1 = GameObject.Find ("PanelHotkeys").transform.GetChild(1); Transform vGm2; for (int i=0; i < 3; i++) { vGm2 = vGm1.GetChild (i); for (int j=0; j < 4; j++) { Variables.panelButtonImageList.Add (vGm2.transform.GetChild (j).GetComponent<Image>()); Variables.cooldownPanelButtonImageList.Add((GameObject.Instantiate(Variables.scriptMainScript.sampleCooldownImage, Vector3.zero,Quaternion.Euler(Vector3.zero)) as GameObject).GetComponent<Image>()); Variables.cooldownPanelButtonImageList [Variables.cooldownPanelButtonImageList.Count-1].gameObject.transform.parent = Variables.panelButtonImageList [Variables.panelButtonImageList.Count-1].gameObject.transform; Variables.cooldownPanelButtonImageList [Variables.cooldownPanelButtonImageList.Count - 1].gameObject.transform.localPosition = Vector3.zero; } } Transform vGm3 = Variables.panelSettingTransform.FindChild ("PanelButton").transform; for (int i =0; i < 12; i++) { Variables.hotkeysTextList.Add(vGm3.GetChild(i).GetChild(0).GetComponent<Text>()); } Transform GO3 = Variables.panelBuffTransform.FindChild("PanelButton").transform; for (int i = 0; i < 10; i++) { Variables.buffButtonObjectList.Add (new SkillObjectButton (GameObject.Instantiate ( Variables.scriptMainScript.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler (Vector3.zero)) as GameObject)); Variables.buffButtonObjectList [i].obj.transform.SetParent (GO3); } for (int i = 0; i < 10; i++) { Variables.debuffButtonObjectList.Add (new SkillObjectButton (GameObject.Instantiate ( Variables.scriptMainScript.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler (Vector3.zero)) as GameObject)); Variables.debuffButtonObjectList [i].obj.transform.SetParent (GO3); Variables.debuffButtonObjectList [i].image.color = new Color(240, 190, 190); } Variables.animEnumsList.Add (Enums.AnimationEnum.Idle); Variables.animEnumsList.Add (Enums.AnimationEnum.Run); Variables.animEnumsList.Add (Enums.AnimationEnum.Walk); Variables.animEnumsList.Add (Enums.AnimationEnum.Attack); Variables.animEnumsList.Add (Enums.AnimationEnum.Cast); Variables.animEnumsList.Add (Enums.AnimationEnum.RangeAttack); Variables.actionButtonList.Add (1); Variables.actionButtonList.Add (2); Variables.actionButtonList.Add (3); Variables.hotkeysList.Add (KeyCode.F1); Variables.hotkeysList.Add (KeyCode.F2); Variables.hotkeysList.Add (KeyCode.F3); Variables.hotkeysList.Add (KeyCode.F4); Variables.hotkeysList.Add (KeyCode.F5); Variables.hotkeysList.Add (KeyCode.F6); Variables.hotkeysList.Add (KeyCode.F7); Variables.hotkeysList.Add (KeyCode.F8); Variables.hotkeysList.Add (KeyCode.F9); Variables.hotkeysList.Add (KeyCode.F10); Variables.hotkeysList.Add (KeyCode.F11); Variables.hotkeysList.Add (KeyCode.F12); Variables.globalBuffList.Add ( new BuffClass(1, 20, 5)); Variables.globalBuffList.Add ( new BuffClass(5, 10, 6)); Variables.globalBuffList.Add ( new BuffClass(10, 5, 3+ Variables.weaponOffset)); Variables.globalBuffList.Add ( new BuffClass(11, 5, 4+ Variables.weaponOffset)); Variables.globalBuffList.Add ( new BuffClass(51, 2, 7)); Variables.globalBuffList.Add ( new BuffClass(52, 2, 8)); Variables.globalBuffList.Add ( new BuffClass(53, 5, 9)); Variables.globalBuffList.Add ( new BuffClass(54, 10, 10)); Variables.globalBuffList.Add ( new BuffClass(12, 5, 11)); Variables.globalBuffList.Add ( new BuffClass(13, 10, 13)); Variables.dragImageObject.SetActive (false); Variables.panelTarget.SetActive (false); Variables.panelSkills.SetActive (false); Variables.panelStatus.SetActive (false); Variables.panelAction.SetActive (false); Variables.panelInventory.SetActive (false); Variables.panelSetting.SetActive (false); Variables.panelResurrection.SetActive (false); Variables.panelOption.SetActive (false); Variables.panelAmount.SetActive (false); Variables.panelConfirmation.SetActive (false); Variables.panelDebug.SetActive (false); Variables.expLVLlist.Add (0); Variables.expLVLlist.Add (20); Variables.expLVLlist.Add (40); Variables.expLVLlist.Add (70); Variables.expLVLlist.Add (100); Variables.expLVLlist.Add (150); //Connection.ConnectionServer (); }
void LoadFields() { GameObject field_template = transform.Find("Fields").Find("Field").gameObject; float height = field_template.GetComponent<RectTransform>().anchorMax.y - field_template.GetComponent<RectTransform>().anchorMin.y; float width = field_template.GetComponent<RectTransform>().anchorMax.x - field_template.GetComponent<RectTransform>().anchorMin.x; float margin_y = height/2; DB db = new DB(); db.Connect (); field_template.SetActive (false); //Leo los campos a usar string sqlQuery = "SELECT * FROM form_fields WHERE enabled = 1 ORDER BY orden ASC"; db.dbcmd.CommandText = sqlQuery; db.reader = db.dbcmd.ExecuteReader(); GameObject last_field = new GameObject(); int input_count = 0; while (db.reader.Read()) { string name = db.reader.GetString(1); string type = db.reader.GetString(2); string placeholder = db.reader.GetString(3); string validation = db.reader.GetString(6); GameObject field = Instantiate(field_template) as GameObject; field.transform.SetParent(transform.Find("Fields")); field.transform.Find("Label").Find ("Text").gameObject.GetComponent<Text>().text = placeholder; field.transform.Find("Input").gameObject.GetComponent<InputField>().placeholder.GetComponent<Text>().text = placeholder; switch(validation){ case "email": field.transform.Find("Input").gameObject.GetComponent<InputField>().contentType = InputField.ContentType.EmailAddress; Navigation nav2 = field.transform.Find("Input").gameObject.GetComponent<InputField>().navigation; nav2.mode = Navigation.Mode.Explicit; //nav.selectOnDown = field.transform.Find("Input").gameObject.GetComponent<Selectable>(); field.transform.Find("Input").gameObject.GetComponent<InputField>().navigation = nav2; break; case "phone": field.transform.Find("Input").gameObject.GetComponent<InputField>().contentType = InputField.ContentType.IntegerNumber; if(last_field != null){ Navigation nav = last_field.transform.Find("Input").gameObject.GetComponent<InputField>().navigation; nav.mode = Navigation.Mode.Explicit; nav.selectOnDown = field.transform.Find("Input").gameObject.GetComponent<Selectable>(); last_field.transform.Find("Input").gameObject.GetComponent<InputField>().navigation = nav; } break; case "dni": field.transform.Find("Input").gameObject.GetComponent<InputField>().contentType = InputField.ContentType.IntegerNumber; break; } field.transform.Find("ID").gameObject.GetComponent<Text>().text = name; field.transform.Find("Validation").gameObject.GetComponent<Text>().text = validation; field.GetComponent<RectTransform>().sizeDelta = Vector2.zero; field.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; float posy; float posx; if(input_count > 2){ posy = 1f - ((input_count-3)*height) - (margin_y*(input_count-3)); posx = 0.525f; }else{ posy = 1f - (input_count*height) - (margin_y*input_count); posx = 0.025f; } field.GetComponent<RectTransform>().anchorMax = new Vector2(posx+width,posy); field.GetComponent<RectTransform>().anchorMin = new Vector2(posx,posy-height); field.tag = "RegisterFormInput"; field.SetActive(true); input_count++; if(type == "select"){ Hashtable options = GetSelectOptions(name); input_options.Add (name,options); EventTrigger eventTrigger = field.GetComponentInChildren<EventTrigger>(); EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); combo_box.title = placeholder; trigger.AddListener((PointerEventData) => {combo_box.related_field = field;combo_box.Fill(options);}); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = EventTriggerType.PointerClick }; eventTrigger.triggers.Add(entry); field.transform.Find("Input").gameObject.GetComponent<InputField>().interactable = false; } /*EventTrigger eventTrigger2 = field.GetComponentInChildren<EventTrigger>(); EventTrigger.TriggerEvent trigger2 = new EventTrigger.TriggerEvent(); trigger2.AddListener((PointerEventData) => {Debug.Log ("sas");}); EventTrigger.Entry entry2 = new EventTrigger.Entry() { callback = trigger2, eventID = EventTriggerType.PointerClick }; eventTrigger2.triggers.Add(entry2);*/ last_field = field; } db.reader.Close(); db.reader = null; db.Disconnect (); }
//Events Initialization For Steering Wheel. void SteeringWheelEventsInit(){ eventTrigger = steeringWheelGameObject.GetComponent<EventTrigger>(); var a = new EventTrigger.TriggerEvent(); a.AddListener( data => { var evData = (PointerEventData)data; data.Use(); steeringWheelPressed = true; steeringWheelTouchPos = evData.position; steeringWheelTempAngle = Vector2.Angle(Vector2.up, evData.position - steeringWheelCenter); }); eventTrigger.triggers.Add(new EventTrigger.Entry{callback = a, eventID = EventTriggerType.PointerDown}); var b = new EventTrigger.TriggerEvent(); b.AddListener( data => { var evData = (PointerEventData)data; data.Use(); steeringWheelTouchPos = evData.position; }); eventTrigger.triggers.Add(new EventTrigger.Entry{callback = b, eventID = EventTriggerType.Drag}); var c = new EventTrigger.TriggerEvent(); c.AddListener( data => { steeringWheelPressed = false; }); eventTrigger.triggers.Add(new EventTrigger.Entry{callback = c, eventID = EventTriggerType.EndDrag}); }
protected void Start() { var clickEvents = new EventTrigger.TriggerEvent(); // USER CLICK clickEvents.AddListener(x => { var position = Camera.main.ScreenToWorldPoint((x as PointerEventData).pointerCurrentRaycast.screenPosition); AutoFireToPosition(position); }); var eventListener = canvas.gameObject.AddComponent<EventTrigger>(); eventListener.triggers.Add(new EventTrigger.Entry { eventID = EventTriggerType.PointerClick, callback = clickEvents }); Player.Main.Clear(); InitializeLevel(); StartCoroutine(GameLoop()); }
public static void AddEventTrigger(EventTrigger eventTrigger, UnityAction action, EventTriggerType triggerType) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action()); // ignore event data // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
void Start() { overlay = transform.parent.Find("OverlayCreate").gameObject; EventTrigger eventTrigger = overlay.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((PointerEventData) => {Toggle();}); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = EventTriggerType.PointerClick }; eventTrigger.triggers.Clear (); eventTrigger.triggers.Add(entry); combo_box = GameObject.FindGameObjectWithTag ("ComboBox").GetComponent<ComboBox>(); container = gameObject.transform.Find ("Container").gameObject; initial_scale = GetComponent<RectTransform> ().localScale; gameObject.SetActive (false); }
private void SetAttacks() { foreach (var button in ChoiseButtons) { Destroy(button.gameObject); } ChoiseButtons.Clear(); if (Fighter.Selected != null) { Atributes atributes = Fighter.Selected.Atributes; foreach(Attack attacks in atributes.Feats) { GameObject newButton = GameObject.Instantiate(ButtonPrefab); newButton.transform.SetParent(transform); Button button = newButton.GetComponent<Button>(); button.onClick.AddListener(delegate { SelectedAttack(Fighter.Selected, attacks); }); EventTrigger eventTrigger = newButton.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent enterTrigger = new EventTrigger.TriggerEvent(); EventTrigger.TriggerEvent exitTrigger = new EventTrigger.TriggerEvent(); enterTrigger.AddListener(delegate { PointerEnter(Fighter.Selected, attacks, button.gameObject); }); exitTrigger.AddListener(delegate { PointerExit(); }); EventTrigger.Entry enterEntry = new EventTrigger.Entry() { callback = enterTrigger, eventID = EventTriggerType.PointerEnter }; EventTrigger.Entry exitEntry = new EventTrigger.Entry() { callback = exitTrigger, eventID = EventTriggerType.PointerExit }; eventTrigger.triggers.Add(enterEntry); eventTrigger.triggers.Add(exitEntry); } } }
public void Fill(Hashtable fields) { GameObject input_template = container.transform.Find ("InputField").gameObject; GameObject input_template_fecha = container.transform.Find ("InputFecha").gameObject; input_template.SetActive (false); input_template_fecha.SetActive (false); float height_input_template = input_template.GetComponent<RectTransform> ().anchorMax.y - input_template.GetComponent<RectTransform> ().anchorMin.y; float height_input_template_fecha = input_template_fecha.GetComponent<RectTransform> ().anchorMax.y - input_template_fecha.GetComponent<RectTransform> ().anchorMin.y; int i = 0; float last_height = 0; foreach (DictionaryEntry field in fields) { GameObject input_object; bool is_fecha = false; float height; if(field.Value.ToString().Contains("Fecha")){ input_object = Instantiate(input_template_fecha.gameObject) as GameObject; is_fecha = true; height = 0.2f; }else{ input_object = Instantiate(input_template.gameObject) as GameObject; height = 0.1f; } input_object.transform.SetParent(input_template.transform.parent); input_object.GetComponent<RectTransform>().sizeDelta = Vector2.zero; input_object.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; Vector2 anchor_max = input_object.GetComponent<RectTransform>().anchorMax; Vector2 anchor_min = input_object.GetComponent<RectTransform>().anchorMin; anchor_max.y = anchor_max.y - (last_height) - (0.01f * i); anchor_min.y = anchor_max.y - height; input_object.GetComponent<RectTransform>().anchorMax = anchor_max; input_object.GetComponent<RectTransform>().anchorMin = anchor_min; input_object.GetComponent<RectTransform>().localScale = new Vector3(1f,1f,1f); if(is_fecha){ input_object.transform.Find("Placeholder").gameObject.GetComponent<Text>().text = field.Value.ToString(); EventTrigger eventTrigger_dia = input_object.transform.Find("Dia").gameObject.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent trigger_dia = new EventTrigger.TriggerEvent(); trigger_dia.AddListener((PointerEventData) => { combo_box.related_field = input_object.transform.Find("Dia").gameObject; combo_box.title = "Día"; int[] dias = Enumerable.Range (1, 31).ToArray (); combo_box.FillFromInts (dias, ""); }); EventTrigger.Entry entry_dia = new EventTrigger.Entry() { callback = trigger_dia, eventID = EventTriggerType.PointerClick }; eventTrigger_dia.triggers.Clear (); eventTrigger_dia.triggers.Add(entry_dia); EventTrigger eventTrigger_mes = input_object.transform.Find("Mes").gameObject.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent trigger_mes = new EventTrigger.TriggerEvent(); trigger_mes.AddListener((PointerEventData) => { combo_box.related_field = input_object.transform.Find("Mes").gameObject; combo_box.title = "Mes"; int[] meses = Enumerable.Range (1, 12).ToArray (); combo_box.FillFromInts (meses, "");; }); EventTrigger.Entry entry_mes = new EventTrigger.Entry() { callback = trigger_mes, eventID = EventTriggerType.PointerClick }; eventTrigger_mes.triggers.Clear (); eventTrigger_mes.triggers.Add(entry_mes); EventTrigger eventTrigger_ano = input_object.transform.Find("Ano").gameObject.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent trigger_ano = new EventTrigger.TriggerEvent(); trigger_ano.AddListener((PointerEventData) => { combo_box.related_field = input_object.transform.Find("Ano").gameObject; combo_box.title = "Año"; int[] years = new int[] {2015,2016,2017,2018,2019,2020}; combo_box.FillFromInts (years, ""); }); EventTrigger.Entry entry_ano = new EventTrigger.Entry() { callback = trigger_ano, eventID = EventTriggerType.PointerClick }; eventTrigger_ano.triggers.Clear (); eventTrigger_ano.triggers.Add(entry_ano); last_height += height_input_template_fecha; }else{ input_object.GetComponent<InputField>().placeholder.GetComponent<Text>().text = field.Value.ToString(); last_height += height_input_template; } input_object.SetActive(true); i ++; } Toggle (); }
static public void Initializat(){ Variables.panelTarget = GameObject.Find ("PanelTarget"); Variables.dragImageObject = GameObject.Find ("DragImage"); Variables.panelAmount = GameObject.Find ("PanelAmount"); Variables.panelResurrection = GameObject.Find ("PanelResurrection"); Variables.panelStatus = GameObject.Find ("PanelStatus"); Variables.panelAction = GameObject.Find ("PanelAction"); Variables.panelInventory = GameObject.Find ("PanelInventory"); Variables.panelSkills = GameObject.Find ("PanelSkills"); Variables.panelOption = GameObject.Find ("PanelOption"); Variables.panelDialog = GameObject.Find ("PanelDialog"); Variables.panelSetting = GameObject.Find ("PanelSetting"); Variables.MiniDescriptionObject = GameObject.Find ("PanelMiniDescription"); Variables.panelTrade = GameObject.Find ("PanelTrade"); Variables.panelConfirmation = GameObject.Find ("PanelConfirmation"); Variables.panelInventoryTransform = Variables.panelInventory.transform; Variables.panelSkillsTransform = Variables.panelSkills.transform; Variables.panelBuffTransform = GameObject.Find ("PanelBuff").transform; Variables.panelSkillsButtonPanelTransform = Variables.panelSkillsTransform.FindChild ("PanelButton").transform; Variables.panelInventoryButtonPanelTransform = Variables.panelInventoryTransform.FindChild ("PanelButton").transform; Variables.panelTradeButton1Transform = GameObject.Find ("PanelTradeButton1").transform; Variables.panelTradeButton2Transform = GameObject.Find ("PanelTradeButton2").transform; Variables.panelHotkeysTransform = GameObject.Find ("PanelHotkeys").transform; Variables.panelStatusTransform = Variables.panelStatus.transform; Variables.panelActionTransform = Variables.panelAction.transform; Variables.panelDialogTransform = Variables.panelDialog.transform; Variables.panelSettingTransform = Variables.panelSetting.transform; Variables.panelTradeTransform = Variables.panelTrade.transform; Variables.scriptButtonValue = GameObject.Find ("ButtonValue").GetComponent<ButtonValue>(); Variables.scriptControlMove = GameObject.Find ("ControlGame").GetComponent<ControlMove>(); Variables.panelTargetBar = GameObject.Find ("PanelTargetHPBarLine").GetComponent<Image>(); Variables.panelPlayerHPBar = GameObject.Find ("PanelPlayerHPBarLine").GetComponent<Image>(); Variables.equipmentImage.Add(GameObject.Find ("WeaponEquipment").GetComponent<Image> ()); Variables.equipmentImage.Add(GameObject.Find ("WeaponEquipment1").GetComponent<Image> ()); Variables.panelPlayerMPBar = GameObject.Find ("PanelPlayerMPBarLine").GetComponent<Image>(); Variables.panelPlayerEXPBar = GameObject.Find ("PanelPlayerEXPBarLine").GetComponent<Image>(); Variables.dragImage = Variables.dragImageObject.GetComponent<Image>(); Variables.amountText = GameObject.Find ("InputFieldAmount").GetComponent<InputField> (); Variables.scriptItemValue = GameObject.Find ("ItemValue").GetComponent<ItemValue>(); Variables.scriptSkillValue = GameObject.Find ("SkillValue").GetComponent<SkillValue>(); Variables.goldText = GameObject.Find ("GoldText").GetComponent<Text> (); Variables.panelTargetText = GameObject.Find ("PanelTargetText").GetComponent<Text> (); Variables.panelPlayerLVLText = GameObject.Find ("TextLVL").GetComponent<Text> (); Variables.panelPlayerHPBarText = GameObject.Find ("PanelPlayerHPBarText").GetComponent<Text> (); Variables.panelPlayerMPBarText = GameObject.Find ("PanelPlayerMPBarText").GetComponent<Text> (); Variables.panelPlayerEXPBarText = GameObject.Find ("PanelPlayerEXPBarText").GetComponent<Text> (); Variables.statusValDamage = GameObject.Find ("ValueDamage").GetComponent<Text> (); Variables.statusValMagDamage = GameObject.Find ("ValueMagDamage").GetComponent<Text> (); Variables.statusValResist = GameObject.Find ("ValueResist").GetComponent<Text> (); Variables.statusValMagResist = GameObject.Find ("ValueMagResist").GetComponent<Text> (); Variables.statusValAttackSpeed = GameObject.Find ("ValueAttackSpeed").GetComponent<Text> (); Variables.statusValCastSpeed = GameObject.Find ("ValueCastSpeed").GetComponent<Text> (); Variables.statusValSpeed = GameObject.Find ("ValueSpeed").GetComponent<Text> (); Variables.statusValEvasion = GameObject.Find ("ValueEvasion").GetComponent<Text> (); Variables.statusValCritChance = GameObject.Find ("ValueCritChance").GetComponent<Text> (); Variables.statusValCritRate = GameObject.Find ("ValueCritRate").GetComponent<Text> (); Variables.MiniDescriptionText = GameObject.Find ("MiniDescription").GetComponent<Text>(); Variables.panelConfirmation.SetActive (false); Variables.panelResurrection.SetActive (false); Variables.panelStatus.SetActive (false); Variables.panelAction.SetActive (false); Variables.panelInventory.SetActive (false); Variables.panelSkills.SetActive (false); Variables.panelOption.SetActive (false); Variables.panelDialog.SetActive (false); Variables.MiniDescriptionObject.SetActive (false); Variables.panelSetting.SetActive (false); Variables.panelTrade.SetActive (false); Variables.panelAmount.SetActive (false); Variables.actionButtonList.Add (1); Variables.actionButtonList.Add (2); Variables.actionButtonList.Add (3); //$SKILL Variables.skillsButtonList.Add (0+Variables.skillOffset); Variables.skillsButtonList.Add (1+Variables.skillOffset); Variables.skillsButtonList.Add (9+Variables.skillOffset); Variables.skillsButtonList.Add (7+Variables.skillOffset); //Variables.skillsButtonList.Add (3+Variables.skillOffset); //Variables.skillsButtonList.Add (4+Variables.skillOffset); //Variables.skillsButtonList.Add (5+Variables.skillOffset); //Variables.skillsButtonList.Add (6+Variables.skillOffset); Variables.traderList1.Add (3); Variables.traderList1.Add (4); Variables.traderList1.Add (13); Variables.traderList1.Add (14); Variables.traderList1.Add (15); Variables.traderList1.Add (19); Variables.traderList1.Add (20); Variables.traderList1.Add (21); Variables.traderList1.Add (22); Variables.traderList1.Add (23); Variables.traderList1.Add (24); Variables.hotkeysList.Add (KeyCode.F1); Variables.hotkeysList.Add (KeyCode.F2); Variables.hotkeysList.Add (KeyCode.F3); Variables.hotkeysList.Add (KeyCode.F4); Variables.hotkeysList.Add (KeyCode.F5); Variables.hotkeysList.Add (KeyCode.F6); Variables.hotkeysList.Add (KeyCode.F7); Variables.hotkeysList.Add (KeyCode.F8); Variables.hotkeysList.Add (KeyCode.F9); Variables.hotkeysList.Add (KeyCode.F10); Variables.hotkeysList.Add (KeyCode.F11); Variables.hotkeysList.Add (KeyCode.F12); //$BUFF Variables.globalBuffList.Add ( new BuffClass(1, 20, 5)); Variables.globalBuffList.Add ( new BuffClass(5, 10, 6)); Variables.globalBuffList.Add ( new BuffClass(10, 5, 3+ Variables.weaponOffset)); Variables.globalBuffList.Add ( new BuffClass(11, 5, 4+ Variables.weaponOffset)); Variables.globalBuffList.Add ( new BuffClass(51, 2, 7)); Variables.globalBuffList.Add ( new BuffClass(52, 2, 8)); Variables.globalBuffList.Add ( new BuffClass(53, 5, 9)); Variables.globalBuffList.Add ( new BuffClass(54, 10, 10)); Variables.globalBuffList.Add ( new BuffClass(12, 5, 11)); Variables.globalBuffList.Add ( new BuffClass(13, 10, 13)); Variables.currentTimeRegeneration = 0; for (int i=0; i< 12; i++) { Variables.panelButtonList.Add (0); } //$BUTTON/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Variables.panelButtonList[0] = 1; Variables.panelButtonList[1] = 2; Variables.panelButtonList[2] = 3; Variables.panelButtonList[3] = 4; Variables.panelButtonList[4] = 5; Variables.panelButtonList[5] = 11; Variables.panelButtonList[6] = 13; Variables.panelButtonList[7] = 9+Variables.weaponOffset; Variables.panelButtonList[8] = 3+Variables.weaponOffset; Variables.panelButtonList[9] = 4+Variables.weaponOffset; Variables.panelButtonList[10] = 0+Variables.weaponOffset; Variables.panelButtonList[11] = 1+Variables.weaponOffset; Transform vGm1 = GameObject.Find ("PanelHotkeys").transform.GetChild(1); Transform vGm2; for (int i=0; i < 3; i++) { vGm2 = vGm1.GetChild (i); for (int j=0; j < 4; j++) { Variables.panelButtonImageList.Add (vGm2.transform.GetChild (j).GetComponent<Image>()); } } Transform vGm3 = Variables.panelSettingTransform.FindChild ("PanelButton").transform; for (int i =0; i < 12; i++) { Variables.hotkeysTextList.Add(vGm3.GetChild(i).GetChild(0).GetComponent<Text>()); } Variables.objectMoveTarget = GameObject.Instantiate (Variables.scriptControlMove.sampleObjectMoveTarget, new Vector3(0,0,0), Quaternion.Euler(0,0,0)) as GameObject; Variables.objectMoveTarget.SetActive (false); Variables.objectMoveTargetTransform = Variables.objectMoveTarget.transform; Variables.personMass.Add(new Person(GameObject.Find("Player"))); GameObject[] objects = GameObject.FindGameObjectsWithTag ("Mob"); foreach (GameObject obj in objects) { Variables.personMass.Add (new Person (obj)); } for (int i = 0; i<10; i++) { Variables.tradeButton1List.Add(0); Variables.tradeButton1ObjectButtonList.Add(new SkillObjectButton(GameObject.Instantiate( Variables.scriptControlMove.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject)); Variables.tradeButton1ObjectButtonList[i].obj.transform.SetParent(Variables.panelTradeButton1Transform); int ii = i; Variables.tradeButton1ObjectButtonList[i].button.onClick.AddListener(delegate { Variables.scriptControlMove.TradeButton1(ii);}); EventTrigger.TriggerEvent t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.BeginDragTradeButton1(ii);}); Variables.tradeButton1ObjectButtonList[i].eventTrigger.triggers.Add(new EventTrigger.Entry{callback = t , eventID = EventTriggerType.BeginDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EndDrag();}); Variables.tradeButton1ObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.EndDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EnterTradeButton1(ii);}); Variables.tradeButton1ObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerEnter}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.ExitTradeButton1();}); Variables.tradeButton1ObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerExit}); Variables.tradeButton2List.Add(0); Variables.tradeButton2ObjectButtonList.Add(new SkillObjectButton(GameObject.Instantiate( Variables.scriptControlMove.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject)); Variables.tradeButton2ObjectButtonList[i].obj.transform.SetParent(Variables.panelTradeButton2Transform); ii = i; Variables.tradeButton2ObjectButtonList[i].button.onClick.AddListener(delegate { Variables.scriptControlMove.TradeButton2(ii);}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.BeginDragTradeButton2(ii);}); Variables.tradeButton2ObjectButtonList[i].eventTrigger.triggers.Add(new EventTrigger.Entry{callback = t , eventID = EventTriggerType.BeginDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EndDrag();}); Variables.tradeButton2ObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.EndDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EnterTradeButton2(ii);}); Variables.tradeButton2ObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerEnter}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.ExitTradeButton2();}); Variables.tradeButton2ObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerExit}); } Transform GO3 = Variables.panelBuffTransform.FindChild("PanelButton").transform; for (int i = 0; i < Variables.globalBuffLineCount; i++) { Variables.buffButtonObjectList.Add (new SkillObjectButton (GameObject.Instantiate ( Variables.scriptControlMove.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler (Vector3.zero)) as GameObject)); Variables.buffButtonObjectList [i].obj.transform.SetParent (GO3); } for (int i = 0; i < Variables.globalDebuffLineCount; i++) { Variables.debuffButtonObjectList.Add (new SkillObjectButton (GameObject.Instantiate ( Variables.scriptControlMove.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler (Vector3.zero)) as GameObject)); Variables.debuffButtonObjectList [i].obj.transform.SetParent (GO3); Variables.debuffButtonObjectList [i].image.color = new Color(240, 190, 190); } for(int i = 0; i<63; i++){ Variables.inventoryButtonList.Add(0); Variables.inventoryAmountList.Add(0); Variables.inventoryObjectButtonList.Add(new SkillObjectButton(GameObject.Instantiate( Variables.scriptControlMove.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject)); Variables.inventoryObjectButtonList[i].obj.transform.SetParent(Variables.panelInventoryButtonPanelTransform); int ii = i; Variables.inventoryObjectButtonList[i].button.onClick.AddListener(delegate { Variables.scriptControlMove.Inventory(ii);}); EventTrigger.TriggerEvent t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.BeginDragInventory(ii);}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add(new EventTrigger.Entry{callback = t , eventID = EventTriggerType.BeginDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EndDrag();}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.EndDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EnterInventoryBut(ii);}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerEnter}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.ExitInventoryBut();}); Variables.inventoryObjectButtonList[i].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.PointerExit}); } //$INVENT Variables.inventoryButtonList [0] = 0+Variables.weaponOffset; Variables.inventoryButtonList [1] = 1+Variables.weaponOffset; Variables.inventoryButtonList [2] = 3+Variables.weaponOffset; Variables.inventoryButtonList [3] = 4+Variables.weaponOffset; Variables.inventoryButtonList [4] = 5+Variables.weaponOffset; Variables.inventoryButtonList [5] = 6+Variables.weaponOffset; Variables.inventoryButtonList [6] = 7+Variables.weaponOffset; Variables.inventoryButtonList [7] = 8+Variables.weaponOffset; Variables.inventoryButtonList [8] = 9+Variables.weaponOffset; Variables.inventoryButtonList [9] = 10+Variables.weaponOffset; Variables.inventoryButtonList [10] = 11+Variables.weaponOffset; Variables.inventoryButtonList [11] = 12+Variables.weaponOffset; Variables.inventoryAmountList [2] = 10; Variables.inventoryAmountList [3] = 10; Variables.inventoryAmountList [4] = 1; Variables.inventoryAmountList [5] = 1; Variables.inventoryAmountList [6] = 1; Variables.inventoryAmountList [7] = 1; Variables.expLVLlist.Add (0); Variables.expLVLlist.Add (20); Variables.expLVLlist.Add (40); Variables.expLVLlist.Add (70); Variables.expLVLlist.Add (100); Variables.expLVLlist.Add (150); for(int i =0; i<Variables.personMass.Count; i++){ Variables.distanceList.Add(0); } Mechanics.AddEXP (0); Variables.personMass [0].weaponNumber = -1; Variables.personMass [0].bodyNumber = -1; for(int i = 0; i < Variables.personMass.Count; i++){ Mechanics.UpdatePlayerStats (i); } }
public void GenerateSettingsFileButtons() { // we need to clear out the children in the list before we generate new ones for (int i = 0; i < widgetList.transform.childCount; i ++) { //widgetList.transform.GetChild(i).gameObject.SetActive(false); Debug.Log("destroying: " + widgetList.transform.GetChild(i).name); Destroy(widgetList.transform.GetChild(i).gameObject); } // we need to clear out the children in the list before we generate new ones for (int i = 0; i < fieldsList.transform.childCount; i ++) { fieldsList.transform.GetChild(i).gameObject.SetActive(false); Debug.Log("destroying: " + fieldsList.transform.GetChild(i).name); Destroy(fieldsList.transform.GetChild(i).gameObject); } foreach(string name in loadedFiles) { GameObject newBut = Instantiate(Resources.Load("WidgetSettings/WidgetButton")) as GameObject; newBut.transform.SetParent(widgetList.transform); newBut.GetComponentInChildren<Text>().text = name; // code to add a listener to the button OnClicked() event EventTrigger eTrigger = newBut.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); // The following line adds the DisplaySettingsFile function as a listener to the EventTrigger on the button we instantiated. trigger.AddListener((eventData)=>displaySettingsPanel.SetActive(true)); trigger.AddListener((eventData)=>DisplaySettingsFile(newBut)); // The next line adds the entry we created to the Event Trigger of the instantiated button. // The entry consists of two parts, the listener we set up earlier, and the EventTriggerType. // The EventTriggerType tells the EventTrigger when to send out the message that the event has occured. // We use PointerClick so we know when the used has clicked on a button. EventTrigger.Entry entry = new EventTrigger.Entry(){callback = trigger, eventID = EventTriggerType.PointerClick}; eTrigger.triggers.Add(entry); } }
static public void UIUpd(){ if(!Variables.drag && Variables.currentPanelButType == 1 && Variables.inventoryButtonList[Variables.currentPanelBut] > 0){ Variables.MiniDescriptionObject.SetActive(true); Variables.MiniDescriptionObject.transform.position = Variables.inventoryObjectButtonList[Variables.currentPanelBut].transform.position + new Vector3(0,37,0); if(Variables.scriptItemValue.itemList[Variables.inventoryButtonList[Variables.currentPanelBut] - Variables.weaponOffset].stack){ Variables.MiniDescriptionText.text = Variables.scriptItemValue.itemList[Variables.inventoryButtonList[Variables.currentPanelBut] - Variables.weaponOffset].name +" ("+Variables.inventoryAmountList[ Variables.currentPanelBut]+")"; } else{ Variables.MiniDescriptionText.text = Variables.scriptItemValue.itemList[Variables.inventoryButtonList[Variables.currentPanelBut] - Variables.weaponOffset].name +""; } } if (Variables.currentPanelButType == -1) { Variables.MiniDescriptionObject.SetActive(false); } if (Variables.personMass[0].targetNumber > -1 && !Variables.personMass [Variables.personMass [0].targetNumber].live) { Variables.personMass[0].targetNumber = -1; } if (Variables.personMass[0].targetNumber == -1) { Variables.panelTarget.SetActive (false); } else { Variables.panelTarget.SetActive (true); Variables.panelTargetText.text = Variables.personMass [Variables.personMass[0].targetNumber].name; Variables.panelTargetBar.fillAmount = Variables.personMass [Variables.personMass[0].targetNumber].hp / Variables.personMass [Variables.personMass[0].targetNumber].max_hp; } if (Variables.personMass [0].weaponNumber > -1) { Variables.equipmentImage[0].sprite = Variables.scriptButtonValue.buttonList [Variables.personMass [0].weaponNumber + Variables.weaponOffset].image; } else{ Variables.equipmentImage[0].sprite = Variables.scriptButtonValue.buttonList[0].image; } if (Variables.personMass [0].bodyNumber > -1) { Variables.equipmentImage[1].sprite = Variables.scriptButtonValue.buttonList [Variables.personMass [0].bodyNumber + Variables.weaponOffset].image; } else{ Variables.equipmentImage[1].sprite = Variables.scriptButtonValue.buttonList[0].image; } for (int i = 0; i < Variables.globalBuffLineCount; i++) { if (Variables.personMass [0].buffList [i].imageId == 0) { Variables.buffButtonObjectList [i].image.enabled = false; } else { Variables.buffButtonObjectList [i].image.enabled = true; Variables.buffButtonObjectList [i].image.sprite = Variables.scriptButtonValue.buttonList [Variables.personMass [0].buffList [i].imageId].image; } } for (int i = 0; i < Variables.globalDebuffLineCount; i++) { if (Variables.personMass [0].debuffList [i].imageId == 0) { Variables.debuffButtonObjectList [i].image.enabled = false; } else { Variables.debuffButtonObjectList [i].image.enabled = true; Variables.debuffButtonObjectList [i].image.sprite = Variables.scriptButtonValue.buttonList [Variables.personMass [0].debuffList [i].imageId].image; } } for (int i = 0; i < 12; i++) { if(Variables.hotkeysList[i] != KeyCode.Escape){ bool ok = false; if(!ok && Variables.hotkeysList[i].ToString().Contains("Alpha")){ Variables.hotkeysTextList[i].text = Variables.hotkeysList[i].ToString().Substring(5); ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Comma"){ Variables.hotkeysTextList[i].text = ","; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Period"){ Variables.hotkeysTextList[i].text = "."; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Slash"){ Variables.hotkeysTextList[i].text = "/"; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Semicolon"){ Variables.hotkeysTextList[i].text = ";"; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Quote"){ Variables.hotkeysTextList[i].text = "'"; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "LeftBracket"){ Variables.hotkeysTextList[i].text = "["; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "RightBracket"){ Variables.hotkeysTextList[i].text = "]"; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Minus"){ Variables.hotkeysTextList[i].text = "-"; ok = true; } if( !ok && Variables.hotkeysList[i].ToString() == "Equals"){ Variables.hotkeysTextList[i].text = "="; ok = true; } if( !ok ){ Variables.hotkeysTextList[i].text = Variables.hotkeysList[i].ToString(); ok = true; } ok = false; }else{ Variables.hotkeysTextList[i].text = ""; } } if(Variables.trade){ } Variables.goldText.text = Variables.gold.ToString (); float skillCeil = Mathf.Ceil (Variables.skillsButtonList.Count / 5f); if(skillCeil != Variables.skillsPanelLines){ if(skillCeil > Variables.skillsPanelLines){ for (;skillCeil!= Variables.skillsPanelLines;){ for(int i = 0; i<5; i++){ Variables.skillsObjectButtonList.Add(new SkillObjectButton(GameObject.Instantiate( Variables.scriptControlMove.sampleSkillObjectButton, Vector3.zero, Quaternion.Euler(Vector3.zero)) as GameObject)); int index = Variables.skillsObjectButtonList.Count - 1; Variables.skillsObjectButtonList[index].obj.transform.SetParent( Variables.panelSkillsButtonPanelTransform); Variables.skillsObjectButtonList[index].button.onClick.AddListener(delegate { Variables.scriptControlMove.Skills(index);}); EventTrigger.TriggerEvent t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.BeginDragSkills(index);}); Variables.skillsObjectButtonList[index].eventTrigger.triggers.Add(new EventTrigger.Entry{callback = t , eventID = EventTriggerType.BeginDrag}); t = new EventTrigger.TriggerEvent(); t.AddListener(delegate { Variables.scriptControlMove.EndDrag();}); Variables.skillsObjectButtonList[index].eventTrigger.triggers.Add (new EventTrigger.Entry{ callback = t , eventID = EventTriggerType.EndDrag}); } Variables.skillsPanelLines ++; } Variables.panelSkillsButtonPanelTransform.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(180,34*skillCeil+6); } if(skillCeil < Variables.skillsPanelLines){ for (;skillCeil!= Variables.skillsPanelLines;){ for(int i = 0; i<5; i++){ GameObject.Destroy (Variables.skillsObjectButtonList[Variables.skillsObjectButtonList.Count-1].obj); Variables.skillsObjectButtonList.RemoveAt(Variables.skillsObjectButtonList.Count-1); } Variables.skillsPanelLines --; } Variables.panelSkillsButtonPanelTransform.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(180,34*skillCeil+6); } } for(int i = 0; i < Variables.skillsPanelLines*5; i++){ if(i < Variables.skillsButtonList.Count){ Variables.skillsObjectButtonList[i].image.sprite = Variables.scriptButtonValue.buttonList[Variables.skillsButtonList[i]].image; }else {Variables.skillsObjectButtonList[i].image.sprite = Variables.scriptButtonValue.buttonList[0].image;} } Variables.panelPlayerHPBar.fillAmount = Variables.personMass[0].hp / Variables.personMass[0].max_hp; Variables.panelPlayerHPBarText.text = (int)(Variables.personMass[0].hp+0.5f) + "/" + (int)(Variables.personMass[0].max_hp+0.5f); Variables.panelPlayerMPBar.fillAmount = Variables.personMass[0].mp / Variables.personMass[0].max_mp; Variables.panelPlayerMPBarText.text = (int)(Variables.personMass[0].mp+0.5f) + "/" + (int)(Variables.personMass[0].max_mp+0.5f); Variables.panelPlayerEXPBar.fillAmount = (Variables.currEXP -Variables.expLVLlist[Variables.currLVL-1])/ ( Variables.expLVLlist[Variables.currLVL]-Variables.expLVLlist[Variables.currLVL-1]); string s = (Variables.currEXP - Variables.expLVLlist [Variables.currLVL - 1]) * 100 / (Variables.expLVLlist [Variables.currLVL] - Variables.expLVLlist [Variables.currLVL - 1]) + ""; if(s.Length > 5){ Variables.panelPlayerEXPBarText.text = s.Substring(0,5) +"%"; }else{ Variables.panelPlayerEXPBarText.text = s+"%"; } Variables.panelPlayerLVLText.text = Variables.currLVL.ToString(); Variables.statusValDamage.text = Variables.personMass[0].damage.ToString(); Variables.statusValMagDamage.text = Variables.personMass[0].magDamage.ToString(); Variables.statusValResist.text = (Variables.personMass[0].resist).ToString()+"%"; Variables.statusValMagResist.text = (Variables.personMass[0].magResist).ToString()+"%"; Variables.statusValAttackSpeed.text = (Variables.personMass[0].attackSpeed).ToString(); Variables.statusValCastSpeed.text = (Variables.personMass[0].castSpeed).ToString(); Variables.statusValSpeed.text = (Variables.personMass[0].speed*100).ToString(); Variables.statusValEvasion.text = (Variables.personMass[0].evasion).ToString()+"%"; Variables.statusValCritChance.text = (Variables.personMass[0].critChance).ToString()+"%"; Variables.statusValCritRate.text = "x"+(Variables.personMass[0].critRate).ToString(); for(int i = 0; i < 12; i++){ Variables.panelButtonImageList[i].sprite = Variables.scriptButtonValue.buttonList[Variables.panelButtonList[i]].image; } for(int i = 0; i < 63; i++){ Variables.inventoryObjectButtonList[i].image.sprite = Variables.scriptButtonValue.buttonList[Variables.inventoryButtonList[i]].image; } for(int i = 0; i < 10; i++){ Variables.tradeButton1ObjectButtonList[i].image.sprite = Variables.scriptButtonValue.buttonList[Variables.tradeButton1List[i]].image; Variables.tradeButton2ObjectButtonList[i].image.sprite = Variables.scriptButtonValue.buttonList[Variables.tradeButton2List[i]].image; } if (Variables.drag) { Variables.dragImageObject.GetComponent<RectTransform>().SetAsLastSibling(); Variables.dragImageObject.SetActive(true); Variables.dragImageObject.transform.position = new Vector3(Input.mousePosition.x+18,Input.mousePosition.y+18,0); Variables.dragImage.sprite = Variables.scriptButtonValue.buttonList[Variables.dragInt].image; } else{ Variables.dragImageObject.SetActive(false); } if (Variables.statusDrag) { Variables.panelStatusTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.actionDrag) { Variables.panelActionTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.hotkeysDrag) { Variables.panelHotkeysTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.skillsDrag) { Variables.panelSkillsTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.inventoryDrag) { Variables.panelInventoryTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.settingDrag) { Variables.panelSettingTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.dialogDrag) { Variables.panelDialogTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.tradeDrag) { Variables.panelTradeTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if (Variables.buffDrag) { Variables.panelBuffTransform.position = Input.mousePosition + Variables.offsetPanelPosition; } if(Variables.settingWork){ if(Input.anyKey){ if(Input.GetKey(KeyCode.F1)){ Appoint(KeyCode.F1);} if(Input.GetKey(KeyCode.F2)){ Appoint(KeyCode.F2);} if(Input.GetKey(KeyCode.F3)){ Appoint(KeyCode.F3);} if(Input.GetKey(KeyCode.F4)){ Appoint(KeyCode.F4);} if(Input.GetKey(KeyCode.F5)){ Appoint(KeyCode.F5);} if(Input.GetKey(KeyCode.F6)){ Appoint(KeyCode.F6);} if(Input.GetKey(KeyCode.F7)){ Appoint(KeyCode.F7);} if(Input.GetKey(KeyCode.F8)){ Appoint(KeyCode.F8);} if(Input.GetKey(KeyCode.F9)){ Appoint(KeyCode.F9);} if(Input.GetKey(KeyCode.F10)){ Appoint(KeyCode.F10);} if(Input.GetKey(KeyCode.F11)){ Appoint(KeyCode.F11);} if(Input.GetKey(KeyCode.F12)){ Appoint(KeyCode.F12);} if(Input.GetKey(KeyCode.Alpha1)){ Appoint(KeyCode.Alpha1);} if(Input.GetKey(KeyCode.Alpha2)){ Appoint(KeyCode.Alpha2);} if(Input.GetKey(KeyCode.Alpha3)){ Appoint(KeyCode.Alpha3);} if(Input.GetKey(KeyCode.Alpha4)){ Appoint(KeyCode.Alpha4);} if(Input.GetKey(KeyCode.Alpha5)){ Appoint(KeyCode.Alpha5);} if(Input.GetKey(KeyCode.Alpha6)){ Appoint(KeyCode.Alpha6);} if(Input.GetKey(KeyCode.Alpha7)){ Appoint(KeyCode.Alpha7);} if(Input.GetKey(KeyCode.Alpha8)){ Appoint(KeyCode.Alpha8);} if(Input.GetKey(KeyCode.Alpha9)){ Appoint(KeyCode.Alpha9);} if(Input.GetKey(KeyCode.Alpha0)){ Appoint(KeyCode.Alpha0);} if(Input.GetKey(KeyCode.Minus)){ Appoint(KeyCode.Minus);} if(Input.GetKey(KeyCode.Equals)){ Appoint(KeyCode.Equals);} if(Input.GetKey(KeyCode.Q)){ Appoint(KeyCode.Q);} if(Input.GetKey(KeyCode.W)){ Appoint(KeyCode.W);} if(Input.GetKey(KeyCode.E)){ Appoint(KeyCode.E);} if(Input.GetKey(KeyCode.R)){ Appoint(KeyCode.R);} if(Input.GetKey(KeyCode.T)){ Appoint(KeyCode.T);} if(Input.GetKey(KeyCode.Y)){ Appoint(KeyCode.Y);} if(Input.GetKey(KeyCode.U)){ Appoint(KeyCode.U);} if(Input.GetKey(KeyCode.I)){ Appoint(KeyCode.I);} if(Input.GetKey(KeyCode.O)){ Appoint(KeyCode.O);} if(Input.GetKey(KeyCode.P)){ Appoint(KeyCode.P);} if(Input.GetKey(KeyCode.LeftBracket)){ Appoint(KeyCode.LeftBracket);} if(Input.GetKey(KeyCode.RightBracket)){ Appoint(KeyCode.RightBracket);} if(Input.GetKey(KeyCode.A)){ Appoint(KeyCode.A);} if(Input.GetKey(KeyCode.S)){ Appoint(KeyCode.S);} if(Input.GetKey(KeyCode.D)){ Appoint(KeyCode.D);} if(Input.GetKey(KeyCode.F)){ Appoint(KeyCode.F);} if(Input.GetKey(KeyCode.G)){ Appoint(KeyCode.G);} if(Input.GetKey(KeyCode.H)){ Appoint(KeyCode.H);} if(Input.GetKey(KeyCode.J)){ Appoint(KeyCode.J);} if(Input.GetKey(KeyCode.K)){ Appoint(KeyCode.K);} if(Input.GetKey(KeyCode.L)){ Appoint(KeyCode.L);} if(Input.GetKey(KeyCode.Semicolon)){ Appoint(KeyCode.Semicolon);} if(Input.GetKey(KeyCode.Quote)){ Appoint(KeyCode.Quote);} if(Input.GetKey(KeyCode.Z)){ Appoint(KeyCode.Z);} if(Input.GetKey(KeyCode.X)){ Appoint(KeyCode.X);} if(Input.GetKey(KeyCode.C)){ Appoint(KeyCode.C);} if(Input.GetKey(KeyCode.V)){ Appoint(KeyCode.V);} if(Input.GetKey(KeyCode.B)){ Appoint(KeyCode.B);} if(Input.GetKey(KeyCode.N)){ Appoint(KeyCode.N);} if(Input.GetKey(KeyCode.M)){ Appoint(KeyCode.M);} if(Input.GetKey(KeyCode.Comma)){ Appoint(KeyCode.Comma);} if(Input.GetKey(KeyCode.Period)){ Appoint(KeyCode.Period);} if(Input.GetKey(KeyCode.Slash)){ Appoint(KeyCode.Slash);} } } }
private void BuildGrids() { for (int y = 0; y < Rule.BoardSize; y++) { for (int x = 0; x < Rule.BoardSize; x++) { var grid = UiHelper.AddChild(gameObject, GridTemplate.gameObject); grid.transform.SetParent(transform, false); grid.transform.localPosition = new Vector3((x * 210) - 210, (y * -210) + 210, 0); var et = new EventTrigger.TriggerEvent(); var localX = x; var localY = y; et.AddListener(_ => OnGridClick(localX, localY)); grid.GetComponent<EventTrigger>().triggers[0].callback = et; _gridRects[x, y] = grid.GetComponent<RectTransform>(); SetMark(x, y, 0); } } GridTemplate.gameObject.SetActive(false); }
void BuildButton(Button buttonPrefab,Sprite image, GameObject panel, Vector2 cornerTopR, Vector2 cornerBottL, Vector3 position, Vector2 size, string bName, int oCost, int fCost) { Button buildB = Instantiate (buttonPrefab, Vector3.zero, Quaternion.identity) as Button; RectTransform rectTransform = buildB.GetComponent<RectTransform> (); rectTransform.SetParent (panel.transform); rectTransform.anchorMax = cornerTopR; rectTransform.anchorMin = cornerBottL; rectTransform.offsetMax = Vector2.zero; rectTransform.offsetMin = Vector2.zero; rectTransform.sizeDelta = size; rectTransform.localPosition = new Vector3(rectTransform.localPosition.x + position.x, rectTransform.localPosition.y - position.y, 0); Text txt = buildB.gameObject.GetComponentInChildren<Text> (); txt.text = bName; string currBuildingName = bName; // Add a new TriggerEvent and add a listener buildB.gameObject.AddComponent<EventTrigger> (); EventTrigger eventTrigger = buildB.GetComponent<EventTrigger> (); EventTrigger.Entry pointerEnterEntry = new EventTrigger.Entry(); EventTrigger.TriggerEvent pointerEnterEvent = new EventTrigger.TriggerEvent(); pointerEnterEntry.eventID = EventTriggerType.PointerEnter; pointerEnterEvent.AddListener((eventData) => CreateIndicator(oCost.ToString() + " ORE " + fCost.ToString() + " FOOD/Day")); pointerEnterEntry.callback = pointerEnterEvent; eventTrigger.triggers.Add(pointerEnterEntry); EventTrigger.Entry pointerExitEntry = new EventTrigger.Entry(); EventTrigger.TriggerEvent pointerExitEvent = new EventTrigger.TriggerEvent(); pointerExitEntry.eventID = EventTriggerType.PointerExit; pointerExitEvent.AddListener((eventData) => PoolIndicator()); pointerExitEntry.callback = pointerExitEvent; eventTrigger.triggers.Add(pointerExitEntry); buildB.onClick.AddListener(() => BuildThis(currBuildingName)); buildB.GetComponent<Image> ().sprite = image; }
public static void AddEventTrigger(EventTrigger eventTrigger, UnityAction<System.Object> action, EventTriggerType triggerType, System.Object eventObj) { // Create a nee TriggerEvent and add a listener EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action(eventObj)); // pass additonal argument to the listener // Create and initialise EventTrigger.Entry using the created TriggerEvent EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; // Add the EventTrigger.Entry to delegates list on the EventTrigger eventTrigger.triggers.Add(entry); }
private void AddEventsToButton(GameObject button, Item item) { //Add OnPointerEnter Event EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); EventTrigger.Entry entry = new EventTrigger.Entry(); trigger.AddListener((eventData) => ShowStats(item)); entry.eventID = EventTriggerType.PointerEnter; entry.callback = trigger; button.GetComponent<EventTrigger>().triggers.Add(entry); /* //Add OnPointerExit Event EventTrigger.TriggerEvent trigger2 = new EventTrigger.TriggerEvent(); EventTrigger.Entry entry2 = new EventTrigger.Entry(); //trigger2.AddListener((eventData) => CloseStats()); entry2.eventID = EventTriggerType.PointerExit; entry2.callback = trigger2; */ }
private void AddEventsToImage(GameObject image, int id) { //Add OnPointerEnter Event EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); EventTrigger.Entry entry = new EventTrigger.Entry(); trigger.AddListener((eventData) => ShowQuestInfo(id)); entry.eventID = EventTriggerType.PointerEnter; entry.callback = trigger; image.GetComponent<EventTrigger>().triggers.Add(entry); //Add OnPointerExit Event EventTrigger.TriggerEvent trigger2 = new EventTrigger.TriggerEvent(); EventTrigger.Entry entry2 = new EventTrigger.Entry(); trigger2.AddListener((eventData) => CloseQuestInfo(id)); entry2.eventID = EventTriggerType.PointerExit; entry2.callback = trigger2; image.GetComponent<EventTrigger>().triggers.Add(entry2); }
private void AddEventTrigger(GameObject button, UnityAction action, EventTriggerType triggerType) { EventTrigger eventTrigger = button.GetComponent<EventTrigger>(); EventTrigger.TriggerEvent trigger = new EventTrigger.TriggerEvent(); trigger.AddListener((eventData) => action()); EventTrigger.Entry entry = new EventTrigger.Entry() { callback = trigger, eventID = triggerType }; eventTrigger.triggers.Add(entry); }