void OnTriggerEnter(Collider other) { // Check Grabber Grabber grab = other.GetComponent <Grabber>(); if (grab != null) { if (grabbers == null) { grabbers = new List <Grabber>(); } if (!grabbers.Contains(grab)) { grabbers.Add(grab); } } // Check UITrigger, which is another type of activator UITrigger trigger = other.GetComponent <UITrigger>(); if (trigger != null) { if (uiTriggers == null) { uiTriggers = new List <UITrigger>(); } if (!uiTriggers.Contains(trigger)) { uiTriggers.Add(trigger); } } }
private static void InstallAnimations(RectTransformElement rte, GameObject gameObject, IReadOnlyLayoutContext context) { AnimationContext animationContext = new AnimationContext(); List <(UIAnimation, AnimationElement)> listOfAnimations = new List <(UIAnimation, AnimationElement)>(); foreach (var anim in rte.Animations) { var constructor = Constructors.GetAnimationConstructor(anim); UIAnimation animation = constructor.Install(gameObject, anim, context); if (!string.IsNullOrEmpty(anim.Key)) { animationContext.AddAnimation(context.ParseString(anim.Key), animation); } listOfAnimations.Add((animation, anim)); } foreach (var pair in listOfAnimations) { var anim = pair.Item2; var animation = pair.Item1; foreach (var trigger in anim.Triggers) { var constructor = Constructors.GetTriggerConstructor(trigger); UITrigger triggerComponent = constructor.Install(gameObject, trigger, context, animationContext); triggerComponent.conditions = ParseConditions(trigger.Conditions, gameObject, context); triggerComponent.instant = context.ParseBool(trigger.Instant); triggerComponent.animation = animation; } } }
private void Update() { RaycastHit hit; bool hits = Physics.Raycast(rig.hmd.position, rig.hmd.forward, out hit, raycastLength, uiActivateMask); if (hits) { UITrigger trigger = hit.transform.GetComponent <UITrigger>(); if (trigger != null && currentUITrigger != trigger) { if (currentUITrigger != null) { currentUITrigger.TriggerUI(false, rig.hmd); } trigger.TriggerUI(true, rig.hmd); currentUITrigger = trigger; } } else { if (currentUITrigger != null) { currentUITrigger.TriggerUI(false, rig.hmd); currentUITrigger = null; } } }
void OnEnable() { uiTrigger = (UITrigger)target; UpdateSerializedProperties(); UpdateButtonNamesPopup(); }
public static UITrigger Get(GameObject go, bool scale = true) { UITrigger uTrigger = go.GetComponent <UITrigger>(); if (uTrigger == null) { uTrigger = go.AddComponent <UITrigger>(); } return(uTrigger); }
protected virtual void ApplyButtonUIEvents() { Button v_button = GetComponent <Button>(); if (v_button != null) { RemoveListener(v_button.onClick, FullSend); if (UITrigger.ContainsFlag(UITriggerEnum.OnPointerClick)) { AddListener(v_button.onClick, FullSend); } } }
void Awake() { //set active false to ensure UITrigger's OnEnable will be called after 'triggerOnButtonClick' and 'dispatchAll' been set already gameObject.SetActive(false); _mButtonClickTrigger = gameObject.AddComponent <UITrigger>(); _mButtonClickTrigger.triggerOnButtonClick = true; _mButtonClickTrigger.dispatchAll = true; _mGameEventTrigger = gameObject.AddComponent <UITrigger>(); _mGameEventTrigger.triggerOnGameEvent = true; _mGameEventTrigger.dispatchAll = true; gameObject.SetActive(true); }
public static void callUpdateAmmoAmount(int index, int ammount) { if (buttonList[index] is UIbutton) { UIbutton tmp = (UIbutton)buttonList[index]; buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>(); dets.updateAmmoAmmount(ammount); } else if (buttonList[index] is UITrigger) { UITrigger tmp = (UITrigger)buttonList[index]; buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>(); dets.updateAmmoAmmount(ammount); } }
public static int getAmmo(XboxAxis axis) { for (int i = 0; i < buttonList.Count; i++) { if (buttonList[i] is UITrigger) { UITrigger tmp = (UITrigger)buttonList[i]; if (tmp.axis == axis) { return(tmp.ammo); } } } return(-1); }
public static bool getAble(XboxAxis axis) { for (int i = 0; i < buttonList.Count; i++) { if (buttonList[i] is UITrigger) { UITrigger tmp = (UITrigger)buttonList[i]; if (tmp.axis == axis) { return(tmp.isAble); } } } Debug.Log("Couldn't find, returning false"); return(false); }
public static void callReload(XboxAxis axis) { Debug.Log("Reloading!"); for (int i = 0; i < buttonList.Count; i++) { if (buttonList[i] is UITrigger) { UITrigger tmp = (UITrigger)buttonList[i]; if (tmp.axis == axis) { buttonDetails dets = tmp.Gamebutton.GetComponent <buttonDetails>(); dets.reload(); break; } } } }
public static int setAmmo(XboxAxis axis, int ammo) { for (int i = 0; i < buttonList.Count; i++) { if (buttonList[i] is UITrigger) { UITrigger tmp = (UITrigger)buttonList[i]; if (tmp.axis == axis) { tmp.ammo = ammo; buttonList[i] = tmp; callUpdateAmmoAmount(i, ammo); return(tmp.ammo); } } } return(-1); }
void OnTriggerExit(Collider other) { Grabber grab = other.GetComponent <Grabber>(); if (grab != null) { if (grabbers.Contains(grab)) { grabbers.Remove(grab); } } UITrigger trigger = other.GetComponent <UITrigger>(); if (trigger != null) { if (uiTriggers.Contains(trigger)) { uiTriggers.Remove(trigger); } } }
public static int resetAmmo(XboxAxis axis) { for (int i = 0; i < buttonList.Count; i++) { if (buttonList[i] is UITrigger) { Debug.Log("iterating"); UITrigger tmp = (UITrigger)buttonList[i]; if (tmp.axis == axis) { tmp.ammo = tmp.fullAmmo; buttonList[i] = tmp; callUpdateAmmoAmount(i, tmp.fullAmmo); Debug.Log("reset ammo with " + tmp.ammo); return(tmp.ammo); } else { Debug.Log("tmp : " + tmp.axis.ToString() + "requested: " + axis.ToString()); } } } return(-1); }
public static string UITriggerString(UITrigger e) { return(e.ToString()); }
public override void OnInspectorGUI() { if (uiTrigger == null) { uiTrigger = (UITrigger)target; } //base.OnInspectorGUI(); serializedObject.Update(); DoozyUIHelper.VerticalSpace(8); #region Header DoozyUIHelper.DrawTexture(DoozyUIResources.BarUiTrigger); #endregion if (isTriggerEnabled) { DoozyUIHelper.DrawTexture(DoozyUIResources.BarEnabled); } else { DoozyUIHelper.DrawTexture(DoozyUIResources.BarDisabled); } if (sp_triggerOnGameEvent.boolValue == false && sp_triggerOnButtonClick.boolValue == false) { DoozyUIHelper.DrawTexture(DoozyUIResources.BarSelectListener); ShowHelpInstructions(); DoozyUIHelper.VerticalSpace(8); ShowHelpCheckbox(); DoozyUIHelper.VerticalSpace(8); sp_gameEvent.stringValue = string.Empty; sp_buttonName.stringValue = string.Empty; isTriggerEnabled = false; buttonNameCurrentIndex = 0; sp_dispatchAll.boolValue = false; #region Listen Game Events sp_triggerOnGameEvent.boolValue = EditorGUILayout.ToggleLeft("Listen for Game Events", sp_triggerOnGameEvent.boolValue); #endregion DoozyUIHelper.VerticalSpace(4); #region Listen Button Clicks sp_triggerOnButtonClick.boolValue = EditorGUILayout.ToggleLeft("Listen for Button Clicks", sp_triggerOnButtonClick.boolValue); #endregion } else { if (sp_triggerOnGameEvent.boolValue) { if (string.IsNullOrEmpty(sp_gameEvent.stringValue) && sp_dispatchAll.boolValue == false) { DoozyUIHelper.DrawTexture(DoozyUIResources.BarEnterGameEvent); isTriggerEnabled = false; } else { isTriggerEnabled = true; } ShowHelpInstructions(); DoozyUIHelper.VerticalSpace(8); ShowHelpCheckbox(); DoozyUIHelper.VerticalSpace(8); EditorGUILayout.BeginHorizontal(); #region Listen Game Events sp_triggerOnGameEvent.boolValue = EditorGUILayout.ToggleLeft("Listen for Game Events", sp_triggerOnGameEvent.boolValue, GUILayout.Width(180)); #endregion GUILayout.Space(8); #region DipatchAll sp_dispatchAll.boolValue = EditorGUILayout.ToggleLeft("Dispatch All Game Events", sp_dispatchAll.boolValue, GUILayout.Width(180)); #endregion GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (sp_dispatchAll.boolValue == false) { #region Game Event DoozyUIHelper.VerticalSpace(4); if (string.IsNullOrEmpty(sp_gameEvent.stringValue)) { DoozyUIHelper.SetZoneColor(DoozyUIHelper.DoozyColor.LightRed); } else { DoozyUIHelper.SetZoneColor(DoozyUIHelper.DoozyColor.LightGreen); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Game Event", GUILayout.Width(80)); sp_gameEvent.stringValue = EditorGUILayout.TextField(sp_gameEvent.stringValue, GUILayout.Width(320)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); DoozyUIHelper.ResetColors(); #endregion } } else if (sp_triggerOnButtonClick.boolValue) { UpdateButtonNamesPopup(); if (string.IsNullOrEmpty(sp_buttonName.stringValue) || sp_buttonName.stringValue.Equals(UIManager.DEFAULT_BUTTON_NAME) && sp_dispatchAll.boolValue == false) { DoozyUIHelper.DrawTexture(DoozyUIResources.BarEnterButtonName); isTriggerEnabled = false; } else { isTriggerEnabled = true; } ShowHelpInstructions(); DoozyUIHelper.VerticalSpace(8); ShowHelpCheckbox(); DoozyUIHelper.VerticalSpace(8); EditorGUILayout.BeginHorizontal(); #region Listen Button Clicks sp_triggerOnButtonClick.boolValue = EditorGUILayout.ToggleLeft("Listen for Button Clicks", sp_triggerOnButtonClick.boolValue, GUILayout.Width(180)); #endregion GUILayout.Space(8); #region DipatchAll sp_dispatchAll.boolValue = EditorGUILayout.ToggleLeft("Dispatch All Button Clicks", sp_dispatchAll.boolValue, GUILayout.Width(180)); #endregion GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (sp_dispatchAll.boolValue == false) { #region Button Name if (UIManager.GetIndexForButtonName(sp_buttonName.stringValue) == -1) //we have a button name that is not in the database; we reset this value { sp_buttonName.stringValue = UIManager.DEFAULT_BUTTON_NAME; } if (sp_buttonName.stringValue.Equals(UIManager.DEFAULT_BUTTON_NAME)) { DoozyUIHelper.SetZoneColor(DoozyUIHelper.DoozyColor.LightRed); } else { DoozyUIHelper.SetZoneColor(DoozyUIHelper.DoozyColor.LightGreen); } DoozyUIHelper.VerticalSpace(4); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Button Name", GUILayout.Width(80)); buttonNameCurrentIndex = UIManager.GetIndexForButtonName(sp_buttonName.stringValue); buttonNameCurrentIndex = EditorGUILayout.Popup(buttonNameCurrentIndex, buttonNames, GUILayout.Width(320)); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); sp_buttonName.stringValue = buttonNames[buttonNameCurrentIndex]; DoozyUIHelper.ResetColors(); #endregion } } DoozyUIHelper.VerticalSpace(8); if (isTriggerEnabled) { ShowTriggerEvent(); } } DoozyUIHelper.ResetColors(); serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(target); }
// Use this for initialization void Start () { secretItem = GetComponent<UITrigger> (); if (secretItem != null && secretItem.found) { switchSprite (); } }
protected virtual void ApplyTriggerUIEvents() { EventTrigger v_eventTrigger = GetComponent <EventTrigger>(); if (v_eventTrigger != null) { //Remove Listeners Before Add foreach (EventTrigger.Entry v_entry in v_eventTrigger.triggers) { if (v_entry != null && v_entry.callback != null) { v_entry.callback.RemoveListener(CallFullSendWithEventData); } } if (UITrigger.ContainsFlag(UITriggerEnum.OnPointerEnter)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.PointerEnter); } if (UITrigger.ContainsFlag(UITriggerEnum.OnPointerExit)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.PointerExit); } if (UITrigger.ContainsFlag(UITriggerEnum.OnPointerDown)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.PointerDown); } if (UITrigger.ContainsFlag(UITriggerEnum.OnPointerUp)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.PointerUp); } if (UITrigger.ContainsFlag(UITriggerEnum.OnPointerClick)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.PointerClick); } if (UITrigger.ContainsFlag(UITriggerEnum.OnDrag)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Drag); } if (UITrigger.ContainsFlag(UITriggerEnum.OnDrop)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Drop); } if (UITrigger.ContainsFlag(UITriggerEnum.OnScroll)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Scroll); } if (UITrigger.ContainsFlag(UITriggerEnum.OnUpdateSelected)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.UpdateSelected); } if (UITrigger.ContainsFlag(UITriggerEnum.OnSelect)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Select); } if (UITrigger.ContainsFlag(UITriggerEnum.OnDeselect)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Deselect); } if (UITrigger.ContainsFlag(UITriggerEnum.OnMove)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Move); } if (UITrigger.ContainsFlag(UITriggerEnum.OnInitializePotentialDrag)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.InitializePotentialDrag); } if (UITrigger.ContainsFlag(UITriggerEnum.OnBeginDrag)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.BeginDrag); } if (UITrigger.ContainsFlag(UITriggerEnum.OnEndDrag)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.EndDrag); } if (UITrigger.ContainsFlag(UITriggerEnum.OnSubmit)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Submit); } if (UITrigger.ContainsFlag(UITriggerEnum.OnCancel)) { AddReplacingEntry(v_eventTrigger, EventTriggerType.Cancel); } } }