/// <summary> /// EventTriggerQuick method for inserting an Drag event into the wrapped EventTrigger. /// </summary> /// <param name="cb">The callback to the event.</param> public void AddOnDrag(UnityEngine.Events.UnityAction <UnityEngine.EventSystems.PointerEventData> cb) { UnityEngine.EventSystems.EventTrigger.Entry e = this.trigger.GetEntry(UnityEngine.EventSystems.EventTriggerType.Drag); e.callback.AddListener((x) => { cb((UnityEngine.EventSystems.PointerEventData)x); }); }
/// <summary> /// EventTriggerQuick method for inserting an Deselect event into the wrapped EventTrigger. /// </summary> /// <param name="cb">The callback to the event.</param> public void AddOnDeselect(UnityEngine.Events.UnityAction <UnityEngine.EventSystems.BaseEventData> cb) { UnityEngine.EventSystems.EventTrigger.Entry e = this.trigger.GetEntry(UnityEngine.EventSystems.EventTriggerType.Deselect); e.callback.AddListener((x) => { cb(x); }); }
/// <summary> /// EventTriggerQuick method for inserting an Move event into the wrapped EventTrigger. /// </summary> /// <param name="cb">The callback to the event.</param> public void AddOnMove(UnityEngine.Events.UnityAction <UnityEngine.EventSystems.AxisEventData> cb) { UnityEngine.EventSystems.EventTrigger.Entry e = this.trigger.GetEntry(UnityEngine.EventSystems.EventTriggerType.Move); e.callback.AddListener((x) => { cb((UnityEngine.EventSystems.AxisEventData)x); }); }
static StackObject *Ctor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *__ret = ILIntepreter.Minus(__esp, 0); var result_of_this_method = new UnityEngine.EventSystems.EventTrigger.Entry(); return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
void SetupEvents() { UnityEngine.EventSystems.EventTrigger trigger = this.GetComponent <UnityEngine.EventSystems.EventTrigger>() ?? this.gameObject.AddComponent <UnityEngine.EventSystems.EventTrigger>(); var onDrag = new UnityEngine.EventSystems.EventTrigger.Entry { eventID = UnityEngine.EventSystems.EventTriggerType.Drag }; onDrag.callback.AddListener((e) => OnDrag(e as UnityEngine.EventSystems.PointerEventData)); trigger.triggers.Add(onDrag); }
static public int constructor(IntPtr l) { try { UnityEngine.EventSystems.EventTrigger.Entry o; o=new UnityEngine.EventSystems.EventTrigger.Entry(); pushValue(l,true); pushValue(l,o); return 2; } catch(Exception e) { return error(l,e); } }
static int _s_set_callback(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.EventSystems.EventTrigger.Entry gen_to_be_invoked = (UnityEngine.EventSystems.EventTrigger.Entry)translator.FastGetCSObj(L, 1); gen_to_be_invoked.callback = (UnityEngine.EventSystems.EventTrigger.TriggerEvent)translator.GetObject(L, 2, typeof(UnityEngine.EventSystems.EventTrigger.TriggerEvent)); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(0); }
static int _g_get_callback(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.EventSystems.EventTrigger.Entry __cl_gen_to_be_invoked = (UnityEngine.EventSystems.EventTrigger.Entry)translator.FastGetCSObj(L, 1); translator.Push(L, __cl_gen_to_be_invoked.callback); } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(1); }
static int _g_get_eventID(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.EventSystems.EventTrigger.Entry gen_to_be_invoked = (UnityEngine.EventSystems.EventTrigger.Entry)translator.FastGetCSObj(L, 1); translator.PushUnityEngineEventSystemsEventTriggerType(L, gen_to_be_invoked.eventID); } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(1); }
public static int constructor(IntPtr l) { try { UnityEngine.EventSystems.EventTrigger.Entry o; o=new UnityEngine.EventSystems.EventTrigger.Entry(); pushValue(l,o); return 1; } catch(Exception e) { LuaDLL.luaL_error(l, e.ToString()); return 0; } }
static int _s_set_eventID(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); try { UnityEngine.EventSystems.EventTrigger.Entry __cl_gen_to_be_invoked = (UnityEngine.EventSystems.EventTrigger.Entry)translator.FastGetCSObj(L, 1); UnityEngine.EventSystems.EventTriggerType __cl_gen_value; translator.Get(L, 2, out __cl_gen_value); __cl_gen_to_be_invoked.eventID = __cl_gen_value; } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(0); }
protected virtual void AddShowDetailsOnSelect(UnityEngine.UI.Button button, string target) { var eventTrigger = button.GetComponent <UnityEngine.EventSystems.EventTrigger>() ?? button.gameObject.AddComponent <UnityEngine.EventSystems.EventTrigger>(); // On joystick navigation: var entry = new UnityEngine.EventSystems.EventTrigger.Entry(); entry.eventID = UnityEngine.EventSystems.EventTriggerType.Select; entry.callback.AddListener((eventData) => { ShowDetailsOnSelect(target); }); eventTrigger.triggers.Add(entry); // On cursor hover: entry = new UnityEngine.EventSystems.EventTrigger.Entry(); entry.eventID = UnityEngine.EventSystems.EventTriggerType.PointerEnter; entry.callback.AddListener((eventData) => { ShowDetailsOnSelect(target); }); eventTrigger.triggers.Add(entry); }
void SetupEvents() { UnityEngine.EventSystems.EventTrigger trigger = this.GetComponent <UnityEngine.EventSystems.EventTrigger>() ?? this.gameObject.AddComponent <UnityEngine.EventSystems.EventTrigger>(); var onPointerEnter = new UnityEngine.EventSystems.EventTrigger.Entry { eventID = UnityEngine.EventSystems.EventTriggerType.PointerEnter }; var onPointerExit = new UnityEngine.EventSystems.EventTrigger.Entry { eventID = UnityEngine.EventSystems.EventTriggerType.PointerExit }; onPointerEnter.callback.AddListener((e) => OnPointerEnter()); onPointerExit.callback.AddListener((e) => OnPointerExit()); trigger.triggers.Add(onPointerEnter); trigger.triggers.Add(onPointerExit); }
static int __CreateInstance(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); if (LuaAPI.lua_gettop(L) == 1) { UnityEngine.EventSystems.EventTrigger.Entry gen_ret = new UnityEngine.EventSystems.EventTrigger.Entry(); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.EventSystems.EventTrigger.Entry constructor!")); }
} /* Update() */ // OnEnable void OnEnable() { bool bOnce = true; // build up buttons foreach (string entry in io.ApollonIOManager.Instance.ListAvailableExperiment()) { // is entry an already loaded button ? if (!this.m_loadedObject.ContainsKey(entry)) { // instantiate UnityEngine.GameObject button = UnityEngine.GameObject.Instantiate(this.buttonPrefab); // attach button.transform.SetParent(this.parentObject.transform, false); // add button click delegate button.GetComponent <UnityEngine.UI.Button>().onClick.AddListener(() => this.OnListButtonClick(entry)); // add cancel trigger event delegate UnityEngine.EventSystems.EventTrigger.Entry cancelEntry = new UnityEngine.EventSystems.EventTrigger.Entry(); cancelEntry.eventID = UnityEngine.EventSystems.EventTriggerType.Cancel; cancelEntry.callback.AddListener(this.OnBackButtonClick); button.GetComponent <UnityEngine.EventSystems.EventTrigger>().triggers.Add(cancelEntry); // then configure button.GetComponentInChildren <UnityEngine.UI.Text>().text = entry; button.SetActive(true); // add to the loaded element this.m_loadedObject.Add(entry, button); this.m_loadedOrder.Add(entry); } /* if() */ } /* for() */ // set selected to the first element if list are not empty if (bOnce && this.m_loadedOrder.Count != 0 && this.m_loadedObject.Count != 0 ) { this.gameObject.GetComponentInChildren <UnityEngine.EventSystems.EventSystem>().firstSelectedGameObject = this.m_loadedObject[this.m_loadedOrder[0]]; bOnce = false; } } /* OnEnable() */
static StackObject *Add_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.EventSystems.EventTrigger.Entry @item = (UnityEngine.EventSystems.EventTrigger.Entry) typeof(UnityEngine.EventSystems.EventTrigger.Entry).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); System.Collections.Generic.List <UnityEngine.EventSystems.EventTrigger.Entry> instance_of_this_method = (System.Collections.Generic.List <UnityEngine.EventSystems.EventTrigger.Entry>) typeof(System.Collections.Generic.List <UnityEngine.EventSystems.EventTrigger.Entry>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Add(@item); return(__ret); }
private void SetupQuestNameUIEvents(UnityEngine.UI.Button button, Quest target) { if (button == null || target == null) { return; } button.onClick.AddListener(() => { OnClickQuest(target); }); if (showDetailsOnFocus) { var trigger = button.GetComponent <UnityEngine.EventSystems.EventTrigger>(); if (trigger == null) { trigger = button.gameObject.AddComponent <UnityEngine.EventSystems.EventTrigger>(); } var entry = new UnityEngine.EventSystems.EventTrigger.Entry(); entry.eventID = UnityEngine.EventSystems.EventTriggerType.PointerEnter; entry.callback.AddListener((eventData) => { OnClickQuest(target); }); trigger.triggers.Add(entry); } }
/// <summary> /// Create a retrieve an EventTrigger.Entry from an EventTrigger. /// /// Extension method to EventTrigger. /// </summary> /// <param name="et">The EventTrigger to process.</param> /// <param name="ty">The type of event to retrieve.</param> /// <returns>The EventTrigger.Entry of event type ty in the EventTrigger.</returns> /// <remarks>If the EventTrigger does not contain the event, one is created.</remarks> public static UnityEngine.EventSystems.EventTrigger.Entry GetEntry( this UnityEngine.EventSystems.EventTrigger et, UnityEngine.EventSystems.EventTriggerType ty) { if (et.triggers == null) { et.triggers = new List <UnityEngine.EventSystems.EventTrigger.Entry>(); } foreach (UnityEngine.EventSystems.EventTrigger.Entry e in et.triggers) { if (e.eventID == ty) { return(e); } } UnityEngine.EventSystems.EventTrigger.Entry ret = new UnityEngine.EventSystems.EventTrigger.Entry(); ret.eventID = ty; et.triggers.Add(ret); return(ret); }
private void OpenMainWindow() { if (mainWindow != null) { Destroy(mainWindow); mainWindow = null; } if (appButton?.toggleButton?.CurrentState == KSP.UI.UIRadioButton.State.False) { return; } UISkinDef skin = UISkinManager.defaultSkin; // main window mainWindow = new GameObject("AdjustableModPanelWindow"); mainWindow.AddComponent <CanvasRenderer> (); var transform = mainWindow.AddComponent <RectTransform> (); var image = mainWindow.AddComponent <UnityEngine.UI.Image> (); image.sprite = skin.window.normal.background; image.type = UnityEngine.UI.Image.Type.Sliced; // put in the center of the screen transform.anchorMin = new Vector2(0.5f, 0.5f); transform.anchorMax = new Vector2(0.5f, 0.5f); transform.pivot = new Vector2(0.5f, 0.5f); var vert = mainWindow.AddComponent <UnityEngine.UI.VerticalLayoutGroup> (); vert.spacing = 3; vert.padding = new RectOffset(5, 5, 5, 5); var horzfitter = mainWindow.AddComponent <UnityEngine.UI.ContentSizeFitter> (); horzfitter.verticalFit = UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize; horzfitter.horizontalFit = UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize; // header var line = new GameObject(); line.AddComponent <RectTransform> (); var horlayout = line.AddComponent <UnityEngine.UI.HorizontalLayoutGroup> (); horlayout.spacing = 5; // header spacing var elem = new GameObject(); elem.AddComponent <RectTransform> (); var layout = elem.AddComponent <UnityEngine.UI.LayoutElement> (); layout.preferredHeight = 30; layout.preferredWidth = 255 + 55; elem.transform.SetParent(line.transform); // header elements foreach (var scene in appScenesNames) { elem = new GameObject(); elem.AddComponent <CanvasRenderer> (); elem.AddComponent <RectTransform> (); layout = elem.AddComponent <UnityEngine.UI.LayoutElement> (); var text = elem.AddComponent <TMPro.TextMeshProUGUI> (); text.text = scene.Value; text.font = UISkinManager.TMPFont; text.fontSize = 14; text.color = Color.white; text.fontStyle = TMPro.FontStyles.Bold; text.alignment = TMPro.TextAlignmentOptions.Center; layout.preferredHeight = 30; layout.preferredWidth = 70; elem.transform.SetParent(line.transform); } line.transform.SetParent(mainWindow.transform); int num = 0; foreach (var mod in descriptors) { if (!mod.unmanageable && mod.defaultScenes != ApplicationLauncher.AppScenes.NEVER && mod.modIcon != null) { num++; } } Transform contentTransform = null; if (num < 11) { contentTransform = mainWindow.transform; } else { // scroller var scrollobj = new GameObject(); transform = scrollobj.AddComponent <RectTransform> (); layout = scrollobj.AddComponent <UnityEngine.UI.LayoutElement> (); layout.preferredHeight = 500; layout.preferredWidth = 630; scrollobj.transform.SetParent(mainWindow.transform); var scroll = scrollobj.AddComponent <UnityEngine.UI.ScrollRect> (); scroll.horizontal = false; scroll.vertical = true; scroll.scrollSensitivity = 10f; var viewport = new GameObject(); viewport.AddComponent <CanvasRenderer> (); transform = viewport.AddComponent <RectTransform> (); viewport.AddComponent <UnityEngine.UI.Image> (); viewport.AddComponent <UnityEngine.UI.Mask> ().showMaskGraphic = false; viewport.transform.SetParent(scrollobj.transform); transform.anchorMin = Vector2.zero; transform.anchorMax = Vector2.one; transform.pivot = new Vector2(0.5f, 0.5f); transform.sizeDelta = Vector2.zero; scroll.viewport = transform; var content = new GameObject(); transform = content.AddComponent <RectTransform> (); content.AddComponent <UnityEngine.UI.VerticalLayoutGroup> (); var fitter = content.AddComponent <UnityEngine.UI.ContentSizeFitter> (); fitter.verticalFit = UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize; fitter.horizontalFit = UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize; content.transform.SetParent(viewport.transform); scroll.content = transform; transform.anchorMin = new Vector2(0f, 1f); transform.anchorMax = new Vector2(0f, 1f); transform.pivot = new Vector2(0f, 1f); transform.sizeDelta = Vector2.zero; // scrollbar var scrollbar = new GameObject(); scrollbar.AddComponent <CanvasRenderer> (); transform = scrollbar.AddComponent <RectTransform> (); image = scrollbar.AddComponent <UnityEngine.UI.Image> (); image.sprite = skin.verticalScrollbar.normal.background; image.type = UnityEngine.UI.Image.Type.Sliced; var scrollbarcomp = scrollbar.AddComponent <UnityEngine.UI.Scrollbar> (); scrollbarcomp.direction = UnityEngine.UI.Scrollbar.Direction.BottomToTop; scrollbar.transform.SetParent(scrollobj.transform); transform.anchorMin = new Vector2(1f, 0f); transform.anchorMax = Vector2.one; transform.pivot = Vector2.one; transform.sizeDelta = new Vector2(20, 0); // scrollbar handle var handle = new GameObject(); handle.AddComponent <CanvasRenderer> (); transform = handle.AddComponent <RectTransform> (); image = handle.AddComponent <UnityEngine.UI.Image> (); image.sprite = skin.verticalScrollbarThumb.normal.background; image.type = UnityEngine.UI.Image.Type.Sliced; scrollbarcomp.targetGraphic = image; scrollbarcomp.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap; var spritestate = scrollbarcomp.spriteState; spritestate.highlightedSprite = skin.verticalScrollbarThumb.highlight.background; spritestate.pressedSprite = skin.verticalScrollbarThumb.active.background; spritestate.disabledSprite = skin.verticalScrollbarThumb.disabled.background; scrollbarcomp.spriteState = spritestate; handle.transform.SetParent(scrollbar.transform); scrollbarcomp.handleRect = transform; scroll.verticalScrollbar = scrollbarcomp; contentTransform = content.transform; // reset config to fix some weirdness scrollbar.SetActive(false); scrollbar.SetActive(true); scrollobj.SetActive(false); scrollobj.SetActive(true); transform.offsetMin = Vector2.zero; transform.offsetMax = Vector2.zero; } foreach (var mod in descriptors) { if (mod.unmanageable || mod.modIcon == null || mod.defaultScenes == ApplicationLauncher.AppScenes.NEVER) { continue; } // mod lines line = new GameObject(); line.AddComponent <RectTransform> (); horlayout = line.AddComponent <UnityEngine.UI.HorizontalLayoutGroup> (); horlayout.spacing = 5; // pinned toggle element elem = new GameObject(); elem.AddComponent <RectTransform> (); layout = elem.AddComponent <UnityEngine.UI.LayoutElement> (); layout.preferredHeight = 50; layout.preferredWidth = 50; if (!GetType().Module.Name.StartsWith(mod.module)) { // toggle var toggle = new GameObject(); toggle.AddComponent <CanvasRenderer> (); transform = toggle.AddComponent <RectTransform> (); transform.anchorMin = new Vector2(0.5f, 0.5f); transform.anchorMax = new Vector2(0.5f, 0.5f); transform.pivot = new Vector2(0.5f, 0.5f); transform.sizeDelta = new Vector2(50, 50); image = toggle.AddComponent <UnityEngine.UI.Image> (); image.sprite = normalPin; image.type = UnityEngine.UI.Image.Type.Sliced; var togglecomp = toggle.AddComponent <UnityEngine.UI.Toggle> (); togglecomp.targetGraphic = image; togglecomp.image.sprite = normalPin; togglecomp.image.type = UnityEngine.UI.Image.Type.Sliced; togglecomp.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap; var spritestatet = togglecomp.spriteState; spritestatet.highlightedSprite = highlightedPin; spritestatet.pressedSprite = activePin; spritestatet.disabledSprite = normalPin; togglecomp.spriteState = spritestatet; // checkbox for toggle var check = new GameObject(); check.AddComponent <CanvasRenderer> (); transform = check.AddComponent <RectTransform> (); check.transform.SetParent(toggle.transform); transform.anchorMin = new Vector2(0f, 0f); transform.anchorMax = new Vector2(1f, 1f); transform.pivot = new Vector2(0.5f, 0.5f); transform.sizeDelta = Vector2.zero; image = check.AddComponent <UnityEngine.UI.Image> (); togglecomp.graphic = image; image.sprite = activePin; image.type = UnityEngine.UI.Image.Type.Sliced; // toggle setup togglecomp.interactable = true; togglecomp.isOn = pinnedMods[mod]; togglecomp.onValueChanged.AddListener((value) => { pinnedMods[mod] = value; Debug.Log("[Adjustable Mod Panel] New pinned value for " + mod.module + ": " + value); forceUpdateCount += 1; }); var navigation = togglecomp.navigation; navigation.mode = UnityEngine.UI.Navigation.Mode.None; togglecomp.navigation = navigation; toggle.transform.SetParent(elem.transform); } elem.transform.SetParent(line.transform); // mod icon elem = new GameObject(); elem.AddComponent <CanvasRenderer> (); elem.AddComponent <RectTransform> (); var rimage = elem.AddComponent <UnityEngine.UI.RawImage> (); rimage.texture = mod.modIcon; layout = elem.AddComponent <UnityEngine.UI.LayoutElement> (); layout.preferredHeight = 50; layout.preferredWidth = 50; elem.transform.SetParent(line.transform); // mod name elem = new GameObject(); elem.AddComponent <CanvasRenderer> (); elem.AddComponent <RectTransform> (); layout = elem.AddComponent <UnityEngine.UI.LayoutElement> (); var text = elem.AddComponent <TMPro.TextMeshProUGUI> (); text.text = mod.module; text.font = UISkinManager.TMPFont; text.fontSize = 14; text.color = Color.white; text.fontStyle = TMPro.FontStyles.Bold; text.alignment = TMPro.TextAlignmentOptions.MidlineLeft; layout.preferredHeight = 50; layout.preferredWidth = 200; elem.transform.SetParent(line.transform); foreach (var scene in appScenesNames) { // mod line elements elem = new GameObject(); elem.AddComponent <RectTransform> (); layout = elem.AddComponent <UnityEngine.UI.LayoutElement> (); layout.preferredHeight = 50; layout.preferredWidth = 70; // toggle var toggle = new GameObject(); toggle.AddComponent <CanvasRenderer> (); transform = toggle.AddComponent <RectTransform> (); transform.anchorMin = new Vector2(0.5f, 0.5f); transform.anchorMax = new Vector2(0.5f, 0.5f); transform.pivot = new Vector2(0.5f, 0.5f); transform.sizeDelta = new Vector2(50, 50); image = toggle.AddComponent <UnityEngine.UI.Image> (); image.sprite = skin.toggle.normal.background; image.type = UnityEngine.UI.Image.Type.Sliced; var togglecomp = toggle.AddComponent <UnityEngine.UI.Toggle> (); togglecomp.targetGraphic = image; togglecomp.image.sprite = skin.toggle.normal.background; togglecomp.image.type = UnityEngine.UI.Image.Type.Sliced; togglecomp.transition = UnityEngine.UI.Selectable.Transition.SpriteSwap; var spritestate = togglecomp.spriteState; spritestate.highlightedSprite = skin.toggle.highlight.background; spritestate.pressedSprite = skin.toggle.active.background; spritestate.disabledSprite = skin.toggle.disabled.background; togglecomp.spriteState = spritestate; // checkbox for toggle var check = new GameObject(); check.AddComponent <CanvasRenderer> (); transform = check.AddComponent <RectTransform> (); check.transform.SetParent(toggle.transform); transform.anchorMin = new Vector2(0f, 0f); transform.anchorMax = new Vector2(1f, 1f); transform.pivot = new Vector2(0.5f, 0.5f); transform.sizeDelta = Vector2.zero; image = check.AddComponent <UnityEngine.UI.Image> (); togglecomp.graphic = image; image.sprite = skin.toggle.active.background; image.type = UnityEngine.UI.Image.Type.Sliced; // parameters var parameters = toggle.AddComponent <ToggleParameters> (); parameters.currentModKey = mod; parameters.toggleModScenes = scene.Key; // checkbox state bool allowed = (mod.defaultScenes & scene.Key) != ApplicationLauncher.AppScenes.NEVER; ApplicationLauncher.AppScenes curvalue = currentScenes[mod]; if (pendingChanges.ContainsKey(mod)) { curvalue = pendingChanges[mod]; } bool enabled = (curvalue & (scene.Key & (~mod.requiredScenes))) != ApplicationLauncher.AppScenes.NEVER; togglecomp.interactable = allowed; togglecomp.isOn = allowed & enabled; if (!allowed) { togglecomp.GetComponent <UnityEngine.UI.Image> ().color = new Color(0f, 0f, 0f, 0.25f); } // special case for "always on" if ((parameters.toggleModScenes & (~mod.requiredScenes)) == ApplicationLauncher.AppScenes.NEVER) { image.color = Color.gray; togglecomp.isOn = true; // just keep it always on togglecomp.onValueChanged.AddListener((value) => { if (!value) { togglecomp.isOn = true; } }); } else { // checkbox callback togglecomp.onValueChanged.AddListener((value) => { ApplicationLauncher.AppScenes currentvalue = currentScenes[mod]; if (pendingChanges.ContainsKey(mod)) { currentvalue = pendingChanges[mod]; } if (value != ((currentvalue & (parameters.toggleModScenes & (~mod.requiredScenes))) != ApplicationLauncher.AppScenes.NEVER)) { if (value) { pendingChanges[mod] = currentvalue | (parameters.toggleModScenes & mod.defaultScenes); } else { pendingChanges[mod] = (currentvalue & (~parameters.toggleModScenes)) | mod.requiredScenes; } Debug.Log("[Adjustable Mod Panel] New value for " + parameters.currentModKey.module + ": " + pendingChanges[mod]); forceUpdateCount += 1; UpdateToggles(); } }); } var navigation = togglecomp.navigation; navigation.mode = UnityEngine.UI.Navigation.Mode.None; togglecomp.navigation = navigation; toggle.transform.SetParent(elem.transform); elem.transform.SetParent(line.transform); } line.transform.SetParent(contentTransform); } // input locks mainWindow.transform.SetParent(MainCanvasUtil.MainCanvas.transform); var trigger = mainWindow.AddComponent <UnityEngine.EventSystems.EventTrigger> (); var onMouseEnter = new UnityEngine.EventSystems.EventTrigger.Entry() { eventID = UnityEngine.EventSystems.EventTriggerType.PointerEnter }; onMouseEnter.callback.AddListener((data) => InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, "adjustablemodpanellock")); trigger.triggers.Add(onMouseEnter); var onMouseExit = new UnityEngine.EventSystems.EventTrigger.Entry() { eventID = UnityEngine.EventSystems.EventTriggerType.PointerExit }; onMouseExit.callback.AddListener((data) => InputLockManager.RemoveControlLock("adjustablemodpanellock")); trigger.triggers.Add(onMouseExit); mainWindow.SetActive(true); }
/// <summary> /// Advance the tutorial in his sequential flow. /// </summary> public void AdvanceTutorial() { if (!gameObject.activeSelf) //block any attempt to advance if tutorial isn't active { return; } switch (m_eTutoState) { case eAnturaSpaceTutoState.ANTURA_ANIM: m_eTutoState = eAnturaSpaceTutoState.COOKIE_BUTTON; TutorialUI.Clear(false); m_oAnturaBehaviour.onAnimationByClick -= AdvanceTutorial; AudioManager.I.StopDialogue(false); AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Intro_Touch, delegate() //dialog Antura { AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Intro_Cookie, delegate() //dialog cookies { AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Tuto_Cookie_1, delegate() //dialog tap for cookies { m_oCookieButton.gameObject.SetActive(true); //after the dialog make appear the cookie button m_oCookieButton.onClick.AddListener(AdvanceTutorial); //the button can call AdvanceTutorial on click //RectTransform _oRectCookieB = m_oCookieButton.gameObject.GetComponent<RectTransform>(); TutorialUI.ClickRepeat(m_oCookieButton.transform.position /*m_oCameraUI.ScreenToWorldPoint(new Vector3(_oRectCookieB.position.x,_oRectCookieB.position.y, m_oCameraUI.nearClipPlane))*/, float.MaxValue, 1); }); }); }); break; case eAnturaSpaceTutoState.COOKIE_BUTTON: m_eTutoState = eAnturaSpaceTutoState.USE_ALL_COOKIES; TutorialUI.Clear(false); m_oCookieButton.onClick.RemoveListener(AdvanceTutorial); AudioManager.I.StopDialogue(false); AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Tuto_Cookie_2); //dialog drag cookies m_bIsDragAnimPlaying = true; DrawRepeatLineOnCookieButton(); //Register delegate to disable draw line after done UnityEngine.EventSystems.EventTrigger.Entry _oEntry = new UnityEngine.EventSystems.EventTrigger.Entry(); _oEntry.eventID = UnityEngine.EventSystems.EventTriggerType.EndDrag; _oEntry.callback.AddListener((data) => { m_bIsDragAnimPlaying = false; }); m_oCookieButton.GetComponent <UnityEngine.EventSystems.EventTrigger>().triggers.Add(_oEntry); break; case eAnturaSpaceTutoState.USE_ALL_COOKIES: m_eTutoState = eAnturaSpaceTutoState.CUSTOMIZE; TutorialUI.Clear(false); AudioManager.I.StopDialogue(false); AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Tuto_Cookie_3, delegate() //dialog get more cookies { AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Custom_1, delegate() //dialog customize { m_oCustomizationButton.gameObject.SetActive(true); //after the dialog make appear the customization button m_oCustomizationButton.onClick.AddListener(AdvanceTutorial); /*AudioManager.I.PlayDialog(Db.LocalizationDataId.AnturaSpace_Custom_2, delegate() //dialog click customize * { * //Not knowing how many object there are, register to all buttons * //foreach (var it in m_oItemsParentUI.GetComponentsInChildren<UnityEngine.UI.Button>()) * //{ * // it.onClick.AddListener(AdvanceTutorial); * //} * m_oCustomizationButton.onClick.AddListener(AdvanceTutorial); * }); */ /*RectTransform _oRectCustomB = m_oCustomizationButton.gameObject.GetComponent<RectTransform>(); * TutorialUI.ClickRepeat(m_oCameraUI.ScreenToWorldPoint(new Vector3(_oRectCustomB.position.x, _oRectCustomB.position.y, m_oCameraUI.nearClipPlane)), float.MaxValue, 1); */ TutorialUI.ClickRepeat(m_oCustomizationButton.transform.position, float.MaxValue, 1); }); }); break; case eAnturaSpaceTutoState.CUSTOMIZE: m_eTutoState = eAnturaSpaceTutoState.FINISH; TutorialUI.Clear(false); /*//Unregister from object buttons * foreach (var it in m_oItemsParentUI.GetComponentsInChildren<UnityEngine.UI.Button>()) * { * it.onClick.RemoveListener(AdvanceTutorial); * }*/ m_oCustomizationButton.onClick.RemoveListener(AdvanceTutorial); GlobalUI.ShowBackButton(true, delegate() { NavigationManager.I.GoToScene(AppScene.Map); }); AudioManager.I.StopDialogue(false); AudioManager.I.PlayDialog(Db.LocalizationDataId.Map_Intro_AnturaSpace, delegate() //dialog go to map { //TutorialUI.ClickRepeat(m_oCameraUI.ScreenToWorldPoint(new Vector3(GlobalUI.I.BackButton.RectT.position.x, GlobalUI.I.BackButton.RectT.position.y, m_oCameraUI.nearClipPlane)), float.MaxValue, 1); }); break; default: break; } }
public void Create(FileBrowseProp prop, FileBrowser browser) { this.prop = prop; this.browser = browser; // // NAV BUTTONS //////////////////////////////////////////////////////////////////////////////// this.backBtn = this.prop.CreateButton(this.transform, ""); if (this.prop.navBackSprite != null) { FileBrowseProp.CreateCenteredImage(this.prop.navBackSprite, backBtn.transform, Vector2.zero); } this.backBtn.onClick.AddListener(() => { this.browser.HistoryGoBack(); }); this.fwdBtn = this.prop.CreateButton(this.transform, ""); if (this.prop.navForwardSprite != null) { FileBrowseProp.CreateCenteredImage(this.prop.navForwardSprite, fwdBtn.transform, Vector2.zero); } this.fwdBtn.onClick.AddListener(() => { this.browser.HistoryGoForward(); }); this.upBtn = this.prop.CreateButton(this.transform, "UpButton"); if (this.prop.navUpSprite != null) { FileBrowseProp.CreateCenteredImage(this.prop.navUpSprite, upBtn.transform, Vector2.zero); } this.upBtn.onClick.AddListener(() => { this.browser.NavigateParent(); }); // // Edit Location //////////////////////////////////////////////////////////////////////////////// GameObject goLoc = new GameObject("EditLoc"); goLoc.transform.SetParent(this.transform); goLoc.transform.localRotation = Quaternion.identity; goLoc.transform.localScale = Vector3.one; UnityEngine.UI.Image editPlate = goLoc.AddComponent <UnityEngine.UI.Image>(); editPlate.sprite = this.prop.inputPlateSprite; editPlate.type = UnityEngine.UI.Image.Type.Sliced; RectTransform rtEditPlate = editPlate.rectTransform; rtEditPlate.anchorMin = Vector2.zero; rtEditPlate.anchorMax = Vector2.one; rtEditPlate.pivot = new Vector2(0.0f, 1.0f); rtEditPlate.offsetMin = Vector2.zero; rtEditPlate.offsetMax = Vector2.zero; this.prop.inputText.Create(goLoc.transform, out this.textInput, "", "InputText"); this.textInput.alignment = TextAnchor.MiddleLeft; RectTransform rtInputTxt = this.textInput.rectTransform; rtInputTxt.anchorMin = Vector2.zero; rtInputTxt.anchorMax = Vector2.one; rtInputTxt.pivot = new Vector2(0.0f, 1.0f); rtInputTxt.offsetMin = new Vector2(this.prop.inputPadding, 0.0f); rtInputTxt.offsetMax = new Vector2(-this.prop.inputPadding, 0.0f); this.editInput = goLoc.AddComponent <UnityEngine.UI.InputField>(); this.editInput.targetGraphic = editPlate; this.editInput.textComponent = this.textInput; this.editInput.onEndEdit.AddListener( (x) => { this.OnInput_PathEndEdit(x); }); this.editInput.lineType = UnityEngine.UI.InputField.LineType.MultiLineSubmit; this.DisableInput(); UnityEngine.EventSystems.EventTrigger et = goLoc.AddComponent <UnityEngine.EventSystems.EventTrigger>(); et.triggers = new List <UnityEngine.EventSystems.EventTrigger.Entry>(); UnityEngine.EventSystems.EventTrigger.Entry evtMDown = new UnityEngine.EventSystems.EventTrigger.Entry(); evtMDown.eventID = UnityEngine.EventSystems.EventTriggerType.PointerClick; evtMDown.callback.AddListener( (x) => { this.OnButton_PathClick((UnityEngine.EventSystems.PointerEventData)x); }); et.triggers.Add(evtMDown); this.created = true; this.RefreshNavigationButtonsInteractivity(); }
/// <summary> /// Retrieve a cached TabAssets for a specific window in the tab system - or /// create and store a new one if none currently exist. /// </summary> /// <param name="tabbedWin">The window to retrive the assets for.</param> /// <param name="rt">The RectTransform to put parent the assets in if they're being created. </param> /// <param name="props">The properties used to give the assets if they're being created.</param> /// <returns></returns> public TabsAssets GetTabAssets(Dock tabbedWin, RectTransform parent, DockProps props) { TabsAssets ret; if (this.assetLookup.TryGetValue(tabbedWin, out ret) == true) { return(ret); } ret = new TabsAssets(); GameObject goTab = new GameObject("Tab asset"); goTab.transform.SetParent(parent); ret.notebookTab = goTab.AddComponent <UnityEngine.UI.Image>(); ret.notebookTab.sprite = props.tabs.tabPlate; ret.notebookTab.type = UnityEngine.UI.Image.Type.Sliced; RectTransform rtTab = ret.notebookTab.rectTransform; rtTab.anchorMin = new Vector2(0.0f, 1.0f); rtTab.anchorMax = new Vector2(0.0f, 1.0f); rtTab.pivot = new Vector2(0.0f, 1.0f); goTab.AddComponent <UnityEngine.UI.Mask>(); ret.notebookButton = goTab.AddComponent <UnityEngine.UI.Button>(); ret.notebookButton.onClick.AddListener( () => { this.dock.activeTab = tabbedWin; this.HandleDock(); }); // Prevent locked windows from being ripped from the tab system. The issue here is // that if it's ripped, then it should turn to a floating window, which locked windows // can't. if (tabbedWin.window.Locked == false) { // If the tag is being dragged, redirect it to the window to // initiate a pull-off. UnityEngine.EventSystems.EventTrigger etTab = goTab.AddComponent <UnityEngine.EventSystems.EventTrigger>(); etTab.triggers = new List <UnityEngine.EventSystems.EventTrigger.Entry>(); UnityEngine.EventSystems.EventTrigger.Entry dragEnt = new UnityEngine.EventSystems.EventTrigger.Entry(); dragEnt.eventID = UnityEngine.EventSystems.EventTriggerType.BeginDrag; dragEnt.callback.AddListener( (x) => { UnityEngine.EventSystems.PointerEventData evt = x as UnityEngine.EventSystems.PointerEventData; // Transform the point from the tab, to the window about to be ripped. Vector2 mouseInTab = goTab.transform.worldToLocalMatrix.MultiplyPoint(evt.position); evt.position = tabbedWin.window.transform.localToWorldMatrix.MultiplyPoint(mouseInTab); // Make sure it's active before handoff. Will be inactive if not the main tab. tabbedWin.window.gameObject.SetActive(true); // Do handoff evt.dragging = true; evt.pointerDrag = tabbedWin.window.gameObject; // Force titlebar drag state Window._StartOutsideDrag(Window.FrameDrag.Position, tabbedWin.window, Vector2.zero); // Make sure it handles OnBeginDrag - certain important drag things are // initialized there. UnityEngine.EventSystems.IBeginDragHandler dragBegin = tabbedWin.window; dragBegin.OnBeginDrag(evt); // Reset styles + shadow this.root.UndockWindow(tabbedWin.window); }); etTab.triggers.Add(dragEnt); } if (tabbedWin.window.Closable == true && tabbedWin.window.Locked == false) { GameObject goCloseBtn = new GameObject("CloseButton"); goCloseBtn.transform.SetParent(rtTab); ret.closeButton = goCloseBtn.AddComponent <UnityEngine.UI.Image>(); ret.closeButton.sprite = props.tabs.innerTabBtn; ret.closeButton.type = UnityEngine.UI.Image.Type.Sliced; RectTransform rtCloseBtn = ret.closeButton.rectTransform; rtCloseBtn.anchorMin = new Vector2(1.0f, 0.0f); rtCloseBtn.anchorMax = new Vector2(1.0f, 1.0f); rtCloseBtn.offsetMin = new Vector2( -this.root.props.tabs.closeBorderRight - this.root.props.tabs.closeWidth, this.root.props.tabs.closeBorderVert); rtCloseBtn.offsetMax = new Vector2( -this.root.props.tabs.closeBorderRight, -this.root.props.tabs.closeBorderVert); UnityEngine.UI.Button closeBtn = goCloseBtn.AddComponent <UnityEngine.UI.Button>(); closeBtn.onClick.AddListener( () => { this.root.CloseWindow(tabbedWin.window); }); if (props.tabs.closeWindowIcon != null) { GameObject goCloseIco = new GameObject("Close"); goCloseIco.transform.SetParent(rtCloseBtn); UnityEngine.UI.Image imgCloseIco = goCloseIco.AddComponent <UnityEngine.UI.Image>(); RectTransform rtClIco = imgCloseIco.rectTransform; imgCloseIco.sprite = props.tabs.closeWindowIcon; rtClIco.anchorMin = new Vector2(0.5f, 0.5f); rtClIco.anchorMax = new Vector2(0.5f, 0.5f); rtClIco.pivot = new Vector2(0.5f, 0.5f); rtClIco.anchoredPosition = Vector2.zero; rtClIco.sizeDelta = props.tabs.closeWindowIcon.rect.size; } } GameObject goText = new GameObject("Text"); goText.transform.SetParent(rtTab); ret.label = goText.AddComponent <UnityEngine.UI.Text>(); ret.label.text = tabbedWin.window.TitlebarText; ret.label.color = props.tabs.tabFontColor; ret.label.fontSize = props.tabs.tabFontSize; ret.label.verticalOverflow = VerticalWrapMode.Truncate; ret.label.horizontalOverflow = HorizontalWrapMode.Wrap; ret.label.alignment = TextAnchor.MiddleCenter; ret.label.font = props.tabs.tabFont; RectTransform rtLabel = ret.label.rectTransform; rtLabel.anchorMin = Vector2.zero; rtLabel.anchorMax = Vector2.one; rtLabel.offsetMin = Vector2.zero; rtLabel.offsetMax = new Vector2(-this.root.props.tabs.closeBorderRight - this.root.props.tabs.closeWidth, 0.0f); rtLabel.pivot = new Vector2(0.5f, 0.5f); this.assetLookup.Add(tabbedWin, ret); return(ret); }
// OnEnable void OnEnable() { bool bOnce = true; // build up buttons foreach (string key in io.ApollonIOManager.Instance.Input.GetKeys()) { // is entry an already loaded item ? if (!this.m_loadedObject.ContainsKey(key)) { // Switch on type common.ApollonTypeSwitch.Do( // get data io.ApollonIOManager.Instance.Input.GetData(key), // case : boolean common.ApollonTypeSwitch.Case<bool>(() => { // instantiate UnityEngine.GameObject toggle = UnityEngine.GameObject.Instantiate(this.togglePrefab); // attach toggle.transform.SetParent(this.parentObject.transform,false); // initalize toggle.GetComponentInChildren<UnityEngine.UI.Toggle>().isOn = (bool)io.ApollonIOManager.Instance.Input.GetData(key); // add button click delegate toggle.GetComponentInChildren<UnityEngine.UI.Toggle>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, value); } ); // add cancel trigger event delegate UnityEngine.EventSystems.EventTrigger.Entry cancelEntry = new UnityEngine.EventSystems.EventTrigger.Entry(); cancelEntry.eventID = UnityEngine.EventSystems.EventTriggerType.Cancel; cancelEntry.callback.AddListener(this.OnBackButtonClick); toggle.GetComponent<UnityEngine.EventSystems.EventTrigger>().triggers.Add(cancelEntry); // then configure toggle.GetComponentInChildren<UnityEngine.UI.Text>().text = key; toggle.SetActive(true); // add to the loaded element this.m_loadedObject.Add(key, toggle); this.m_loadedOrder.Add(key); }), common.ApollonTypeSwitch.Case<int>(() => { // instantiate UnityEngine.GameObject slider = UnityEngine.GameObject.Instantiate(this.sliderPrefab); // attach slider.transform.SetParent(this.parentObject.transform, false); // configure slider.GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToInt32(io.ApollonIOManager.Instance.Input.GetData(key)); if (io.ApollonIOManager.Instance.Input.GetRangeMetadata(key) != null) { slider.GetComponentInChildren<UnityEngine.UI.Slider>().minValue = io.ApollonIOManager.Instance.Input.GetRangeMetadata(key).Min; slider.GetComponentInChildren<UnityEngine.UI.Slider>().maxValue = io.ApollonIOManager.Instance.Input.GetRangeMetadata(key).Max; } slider.GetComponentInChildren<UnityEngine.UI.InputField>().text = System.Convert.ToString(io.ApollonIOManager.Instance.Input.GetData(key)); // add delegate // slider -> data slider.GetComponentInChildren<UnityEngine.UI.Slider>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, System.Convert.ToInt32(value)); } ); // slider -> input field slider.GetComponentInChildren<UnityEngine.UI.Slider>().onValueChanged.AddListener( (value) => { slider.GetComponentInChildren<UnityEngine.UI.InputField>().text = System.Convert.ToString(System.Convert.ToInt32(value)); } ); // input field -> data slider.GetComponentInChildren<UnityEngine.UI.InputField>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, System.Convert.ToInt32(value)); } ); // input field -> slider slider.GetComponentInChildren<UnityEngine.UI.InputField>().onValueChanged.AddListener( (value) => { slider.GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToSingle(value); } ); // add cancel trigger event delegate UnityEngine.EventSystems.EventTrigger.Entry cancelEntry = new UnityEngine.EventSystems.EventTrigger.Entry(); cancelEntry.eventID = UnityEngine.EventSystems.EventTriggerType.Cancel; cancelEntry.callback.AddListener(this.OnBackButtonClick); slider.GetComponent<UnityEngine.EventSystems.EventTrigger>().triggers.Add(cancelEntry); // then configure slider.GetComponentInChildren<UnityEngine.UI.Text>().text = key; slider.SetActive(true); // add to the loaded element this.m_loadedObject.Add(key, slider); this.m_loadedOrder.Add(key); }), common.ApollonTypeSwitch.Case<uint>(() => { // instantiate UnityEngine.GameObject slider = UnityEngine.GameObject.Instantiate(this.sliderPrefab); // attach slider.transform.SetParent(this.parentObject.transform, false); // configure slider.GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToUInt32(io.ApollonIOManager.Instance.Input.GetData(key)); if (io.ApollonIOManager.Instance.Input.GetRangeMetadata(key) != null) { slider.GetComponentInChildren<UnityEngine.UI.Slider>().minValue = io.ApollonIOManager.Instance.Input.GetRangeMetadata(key).Min; slider.GetComponentInChildren<UnityEngine.UI.Slider>().maxValue = io.ApollonIOManager.Instance.Input.GetRangeMetadata(key).Max; } slider.GetComponentInChildren<UnityEngine.UI.InputField>().text = System.Convert.ToString(io.ApollonIOManager.Instance.Input.GetData(key)); // add delegate // slider -> data slider.GetComponentInChildren<UnityEngine.UI.Slider>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, System.Convert.ToUInt32(value)); } ); // slider -> input field slider.GetComponentInChildren<UnityEngine.UI.Slider>().onValueChanged.AddListener( (value) => { slider.GetComponentInChildren<UnityEngine.UI.InputField>().text = System.Convert.ToString(System.Convert.ToUInt32(value)); } ); // input field -> data slider.GetComponentInChildren<UnityEngine.UI.InputField>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, System.Convert.ToUInt32(value)); } ); // input field -> slider slider.GetComponentInChildren<UnityEngine.UI.InputField>().onValueChanged.AddListener( (value) => { slider.GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToSingle(value); } ); // add cancel trigger event delegate UnityEngine.EventSystems.EventTrigger.Entry cancelEntry = new UnityEngine.EventSystems.EventTrigger.Entry(); cancelEntry.eventID = UnityEngine.EventSystems.EventTriggerType.Cancel; cancelEntry.callback.AddListener(this.OnBackButtonClick); slider.GetComponent<UnityEngine.EventSystems.EventTrigger>().triggers.Add(cancelEntry); // then configure slider.GetComponentInChildren<UnityEngine.UI.Text>().text = key; slider.SetActive(true); // add to the loaded element this.m_loadedObject.Add(key, slider); this.m_loadedOrder.Add(key); }), common.ApollonTypeSwitch.Case<double>(() => { // instantiate UnityEngine.GameObject slider = UnityEngine.GameObject.Instantiate(this.sliderPrefab); // attach slider.transform.SetParent(this.parentObject.transform, false); // configure slider.GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToSingle(io.ApollonIOManager.Instance.Input.GetData(key)); if (io.ApollonIOManager.Instance.Input.GetRangeMetadata(key) != null) { slider.GetComponentInChildren<UnityEngine.UI.Slider>().minValue = io.ApollonIOManager.Instance.Input.GetRangeMetadata(key).Min; slider.GetComponentInChildren<UnityEngine.UI.Slider>().maxValue = io.ApollonIOManager.Instance.Input.GetRangeMetadata(key).Max; } slider.GetComponentInChildren<UnityEngine.UI.InputField>().text = System.Convert.ToString(io.ApollonIOManager.Instance.Input.GetData(key)); // add delegate // slider -> data slider.GetComponentInChildren<UnityEngine.UI.Slider>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, System.Convert.ToDouble(value)); } ); // slider -> input field slider.GetComponentInChildren<UnityEngine.UI.Slider>().onValueChanged.AddListener( (value) => { slider.GetComponentInChildren<UnityEngine.UI.InputField>().text = System.Convert.ToString(System.Convert.ToDouble(value)); } ); // input field -> data slider.GetComponentInChildren<UnityEngine.UI.InputField>().onValueChanged.AddListener( (value) => { io.ApollonIOManager.Instance.Input.SetData(key, System.Convert.ToDouble(value)); } ); // input field -> slider slider.GetComponentInChildren<UnityEngine.UI.InputField>().onValueChanged.AddListener( (value) => { slider.GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToSingle(value); } ); // add cancel trigger event delegate UnityEngine.EventSystems.EventTrigger.Entry cancelEntry = new UnityEngine.EventSystems.EventTrigger.Entry(); cancelEntry.eventID = UnityEngine.EventSystems.EventTriggerType.Cancel; cancelEntry.callback.AddListener(this.OnBackButtonClick); slider.GetComponent<UnityEngine.EventSystems.EventTrigger>().triggers.Add(cancelEntry); // then configure slider.GetComponentInChildren<UnityEngine.UI.Text>().text = key; slider.SetActive(true); // add to the loaded element this.m_loadedObject.Add(key, slider); this.m_loadedOrder.Add(key); }) ); /* TypeSwitch */ // if it is already there, then we should update values } else { // Switch on type common.ApollonTypeSwitch.Do( // get data io.ApollonIOManager.Instance.Input.GetData(key), // case : boolean common.ApollonTypeSwitch.Case<bool>(() => { // update this.m_loadedObject[key].GetComponentInChildren<UnityEngine.UI.Toggle>().isOn = (bool)io.ApollonIOManager.Instance.Input.GetData(key); }), common.ApollonTypeSwitch.Case<int>(() => { // update this.m_loadedObject[key].GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToInt32(io.ApollonIOManager.Instance.Input.GetData(key)); }), common.ApollonTypeSwitch.Case<uint>(() => { // update this.m_loadedObject[key].GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToUInt32(io.ApollonIOManager.Instance.Input.GetData(key)); }), common.ApollonTypeSwitch.Case<double>(() => { // update this.m_loadedObject[key].GetComponentInChildren<UnityEngine.UI.Slider>().value = System.Convert.ToSingle(io.ApollonIOManager.Instance.Input.GetData(key)); }) ); /* TypeSwitch */ } /* if() */ } /* for() */ // set selected to the first element if list are not empty if (bOnce && this.m_loadedOrder.Count != 0 && this.m_loadedObject.Count != 0 ) { this.gameObject.GetComponentInChildren<UnityEngine.EventSystems.EventSystem>().firstSelectedGameObject = this.m_loadedObject[this.m_loadedOrder[0]]; bOnce = false; } } /* OnEnable() */