public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go != null) { _dropDown = _go.GetComponent <UnityEngine.UI.Dropdown>(); } if (_dropDown != null) { _dropDown.ClearOptions(); } Finish(); }
static StackObject *set_alphaFadeSpeed_15(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.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); System.Single @value = *(float *)&ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.alphaFadeSpeed = value; return(__ret); }
static StackObject *set_value_2(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); System.Int32 @value = ptr_of_this_method->Value; ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0); __intp.Free(ptr_of_this_method); instance_of_this_method.value = value; return(__ret); }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go != null) { _dropDown = _go.GetComponent <UnityEngine.UI.Dropdown>(); } GetValue(); if (!everyFrame) { Finish(); } }
static StackObject *OnCancel_26(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.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.BaseEventData @eventData = (UnityEngine.EventSystems.BaseEventData) typeof(UnityEngine.EventSystems.BaseEventData).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.OnCancel(@eventData); return(__ret); }
static StackObject *set_onValueChanged_13(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.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.UI.Dropdown.DropdownEvent @value = (UnityEngine.UI.Dropdown.DropdownEvent) typeof(UnityEngine.UI.Dropdown.DropdownEvent).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.onValueChanged = value; return(__ret); }
static StackObject *set_options_11(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); System.Collections.Generic.List <UnityEngine.UI.Dropdown.OptionData> @value = (System.Collections.Generic.List <UnityEngine.UI.Dropdown.OptionData>) typeof(System.Collections.Generic.List <UnityEngine.UI.Dropdown.OptionData>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.options = value; return(__ret); }
static StackObject *set_itemImage_9(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.UI.Image @value = (UnityEngine.UI.Image) typeof(UnityEngine.UI.Image).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.itemImage = value; return(__ret); }
static StackObject *AddOptions_22(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.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); System.Collections.Generic.List <UnityEngine.Sprite> @options = (System.Collections.Generic.List <UnityEngine.Sprite>) typeof(System.Collections.Generic.List <UnityEngine.Sprite>).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.AddOptions(@options); return(__ret); }
private void Awake() { hostDropdown = GetComponent <UnityEngine.UI.Dropdown>(); if (initalizeMode == UixSyncInitializationMode.MatchVariable) { internalUpdate = true; if (valueVariable != null) { hostDropdown.value = valueVariable.Value; } if (optionVariable != null) { hostDropdown.options.Clear(); hostDropdown.options.AddRange(optionVariable.Value); } hostDropdown.RefreshShownValue(); internalUpdate = false; } else if (initalizeMode == UixSyncInitializationMode.MatchUiControl && valueVariable != null) { internalUpdate = true; if (valueVariable != null) { valueVariable.Value = hostDropdown.value; } if (optionVariable != null) { optionVariable.Value = hostDropdown.options; } internalUpdate = false; } hostDropdown.onValueChanged.AddListener(HandleChange); }
static int _m_RefreshShownValue(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Dropdown __cl_gen_to_be_invoked = (UnityEngine.UI.Dropdown)translator.FastGetCSObj(L, 1); try { { __cl_gen_to_be_invoked.RefreshShownValue( ); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static StackObject *get_onValueChanged_12(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); UnityEngine.UI.Dropdown instance_of_this_method = (UnityEngine.UI.Dropdown) typeof(UnityEngine.UI.Dropdown).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.onValueChanged; object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
static int _m_Hide(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Dropdown gen_to_be_invoked = (UnityEngine.UI.Dropdown)translator.FastGetCSObj(L, 1); { gen_to_be_invoked.Hide( ); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public static void addBulkSelectRefresh(this UnityEngine.UI.Dropdown d, string selectOption, object objectToGetList, string methodName) { d.options.Clear(); List <string> stringList = (List <string>)objectToGetList.GetType().GetMethod(methodName).Invoke(objectToGetList, null); foreach (string s in stringList) { d.options.Add(new UnityEngine.UI.Dropdown.OptionData() { text = s }); } for (int i = 0; i < d.options.Count; i++) { if (String.Equals(d.options[i].text, selectOption)) { d.value = i; d.RefreshShownValue(); break; } } }
static int _m_OnCancel(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Dropdown __cl_gen_to_be_invoked = (UnityEngine.UI.Dropdown)translator.FastGetCSObj(L, 1); try { { UnityEngine.EventSystems.BaseEventData eventData = (UnityEngine.EventSystems.BaseEventData)translator.GetObject(L, 2, typeof(UnityEngine.EventSystems.BaseEventData)); __cl_gen_to_be_invoked.OnCancel(eventData); return(0); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } }
static int _m_OnPointerClick(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Dropdown gen_to_be_invoked = (UnityEngine.UI.Dropdown)translator.FastGetCSObj(L, 1); { UnityEngine.EventSystems.PointerEventData _eventData = (UnityEngine.EventSystems.PointerEventData)translator.GetObject(L, 2, typeof(UnityEngine.EventSystems.PointerEventData)); gen_to_be_invoked.OnPointerClick(_eventData); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_SetValueWithoutNotify(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); UnityEngine.UI.Dropdown gen_to_be_invoked = (UnityEngine.UI.Dropdown)translator.FastGetCSObj(L, 1); { int _input = LuaAPI.xlua_tointeger(L, 2); gen_to_be_invoked.SetValueWithoutNotify(_input); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
/// <summary> /// Read the data using the reader. /// </summary> /// <param name="reader">Reader.</param> public override object Read(ISaveGameReader reader) { UnityEngine.UI.Dropdown dropdown = SaveGameType.CreateComponent <UnityEngine.UI.Dropdown> (); ReadInto(dropdown, reader); return(dropdown); }
/// <summary> /// Read the data into the specified value. /// </summary> /// <param name="value">Value.</param> /// <param name="reader">Reader.</param> public override void ReadInto(object value, ISaveGameReader reader) { UnityEngine.UI.Dropdown dropdown = (UnityEngine.UI.Dropdown)value; foreach (string property in reader.Properties) { switch (property) { case "template": if (dropdown.template == null) { dropdown.template = reader.ReadProperty <UnityEngine.RectTransform> (); } else { reader.ReadIntoProperty <UnityEngine.RectTransform> (dropdown.template); } break; case "captionText": if (dropdown.captionText == null) { dropdown.captionText = reader.ReadProperty <UnityEngine.UI.Text> (); } else { reader.ReadIntoProperty <UnityEngine.UI.Text> (dropdown.captionText); } break; case "captionImage": if (dropdown.captionImage == null) { dropdown.captionImage = reader.ReadProperty <UnityEngine.UI.Image> (); } else { reader.ReadIntoProperty <UnityEngine.UI.Image> (dropdown.captionImage); } break; case "itemText": if (dropdown.itemText == null) { dropdown.itemText = reader.ReadProperty <UnityEngine.UI.Text> (); } else { reader.ReadIntoProperty <UnityEngine.UI.Text> (dropdown.itemText); } break; case "itemImage": if (dropdown.itemImage == null) { dropdown.itemImage = reader.ReadProperty <UnityEngine.UI.Image> (); } else { reader.ReadIntoProperty <UnityEngine.UI.Image> (dropdown.itemImage); } break; case "options": dropdown.options = reader.ReadProperty <System.Collections.Generic.List <UnityEngine.UI.Dropdown.OptionData> > (); break; case "value": dropdown.value = reader.ReadProperty <System.Int32> (); break; case "navigation": dropdown.navigation = reader.ReadProperty <UnityEngine.UI.Navigation> (); break; case "transition": dropdown.transition = reader.ReadProperty <UnityEngine.UI.Selectable.Transition> (); break; case "colors": dropdown.colors = reader.ReadProperty <UnityEngine.UI.ColorBlock> (); break; case "spriteState": dropdown.spriteState = reader.ReadProperty <UnityEngine.UI.SpriteState> (); break; case "animationTriggers": dropdown.animationTriggers = reader.ReadProperty <UnityEngine.UI.AnimationTriggers> (); break; case "targetGraphic": Type targetGraphicType = Type.GetType(reader.ReadProperty <System.String> ()); if (dropdown.targetGraphic == null) { dropdown.targetGraphic = (UnityEngine.UI.Graphic)reader.ReadProperty(targetGraphicType); } else { reader.ReadIntoProperty(dropdown.targetGraphic); } break; case "interactable": dropdown.interactable = reader.ReadProperty <System.Boolean> (); break; case "image": if (dropdown.image == null) { dropdown.image = reader.ReadProperty <UnityEngine.UI.Image> (); } else { reader.ReadIntoProperty <UnityEngine.UI.Image> (dropdown.image); } break; case "useGUILayout": dropdown.useGUILayout = reader.ReadProperty <System.Boolean> (); break; case "enabled": dropdown.enabled = reader.ReadProperty <System.Boolean> (); break; case "tag": dropdown.tag = reader.ReadProperty <System.String> (); break; case "name": dropdown.name = reader.ReadProperty <System.String> (); break; case "hideFlags": dropdown.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> (); break; } } }
public static bool HSceneSpriteChaChoice_ChangeChaOptions_Patch(HScene.AnimationListInfo info, HSceneSpriteChaChoice __instance, UnityEngine.UI.Dropdown ___dropdown, Manager.HSceneManager ___hSceneManager) { __instance.FeMaleActive[0] = !info.fileFemale.IsNullOrEmpty(); __instance.FeMaleActive[1] = !info.fileFemale2.IsNullOrEmpty(); __instance.MaleActive[0] = !info.fileMale.IsNullOrEmpty(); __instance.MaleActive[1] = !info.fileMale2.IsNullOrEmpty(); if (___hSceneManager.numFemaleClothCustom == 0 || (___hSceneManager.numFemaleClothCustom < 2) ? __instance.FeMaleActive[___hSceneManager.numFemaleClothCustom] : __instance.MaleActive[___hSceneManager.numFemaleClothCustom - 2]) { return(false); } ___hSceneManager.numFemaleClothCustom = 0; ___dropdown.value = 0; return(false); }
private void Reset() { dropdown = transform.GetComponent <UnityEngine.UI.Dropdown>(); }
protected override bool ExecCommand(StoryInstance instance, long delta) { UnityEngine.GameObject obj = m_Obj.Value as UnityEngine.GameObject; if (null != obj) { UiStoryInitializer initer = obj.GetComponent <UiStoryInitializer>(); if (null != initer) { UiStoryEventHandler handler = obj.GetComponent <UiStoryEventHandler>(); if (null == handler) { handler = obj.AddComponent <UiStoryEventHandler>(); } if (null != handler) { int ct = m_VarInfos.Count; for (int ix = 0; ix < ct; ++ix) { string name = m_VarInfos[ix].m_VarName.Value; string path = m_VarInfos[ix].m_ControlPath.Value; UnityEngine.GameObject ctrl = Utility.FindChildObjectByPath(obj, path); AddVariable(instance, name, ctrl); } handler.WindowName = initer.WindowName; var list = m_Inputs; for (int k = 0; k < list.Count; ++k) { string path = list[k].Value; var comp = Utility.FindComponentInChildren <UnityEngine.UI.InputField>(obj, path); handler.InputLabels.Add(comp); } list = m_Toggles; for (int k = 0; k < list.Count; ++k) { string path = list[k].Value; var comp = Utility.FindComponentInChildren <UnityEngine.UI.Toggle>(obj, path); handler.InputToggles.Add(comp); } list = m_Sliders; for (int k = 0; k < list.Count; ++k) { string path = list[k].Value; var comp = Utility.FindComponentInChildren <UnityEngine.UI.Slider>(obj, path); handler.InputSliders.Add(comp); } list = m_DropDowns; for (int k = 0; k < list.Count; ++k) { string path = list[k].Value; var comp = Utility.FindComponentInChildren <UnityEngine.UI.Dropdown>(obj, path); handler.InputDropdowns.Add(comp); } ct = m_EventInfos.Count; for (int ix = 0; ix < ct; ++ix) { string evt = m_EventInfos[ix].m_Event.Value; string tag = m_EventInfos[ix].m_Tag.Value; string path = m_EventInfos[ix].m_Path.Value; if (evt == "button") { UnityEngine.UI.Button button = Utility.FindComponentInChildren <UnityEngine.UI.Button>(obj, path); button.onClick.AddListener(() => { handler.OnClickHandler(tag); }); } else if (evt == "toggle") { UnityEngine.UI.Toggle toggle = Utility.FindComponentInChildren <UnityEngine.UI.Toggle>(obj, path); toggle.onValueChanged.AddListener((bool val) => { handler.OnToggleHandler(tag, val); }); } else if (evt == "dropdown") { UnityEngine.UI.Dropdown dropdown = Utility.FindComponentInChildren <UnityEngine.UI.Dropdown>(obj, path); dropdown.onValueChanged.AddListener((int val) => { handler.OnDropdownHandler(tag, val); }); } else if (evt == "slider") { UnityEngine.UI.Slider slider = Utility.FindComponentInChildren <UnityEngine.UI.Slider>(obj, path); slider.onValueChanged.AddListener((float val) => { handler.OnSliderHandler(tag, val); }); } else if (evt == "input") { UnityEngine.UI.InputField input = Utility.FindComponentInChildren <UnityEngine.UI.InputField>(obj, path); input.onEndEdit.AddListener((string val) => { handler.OnInputHandler(tag, val); }); } } } } } return(false); }
/*public static void SetActionOnStringEditorUI(StringEditorUI field, Action<string> action) * { * field?.inputField.onValueChanged.RemoveAllListeners(); * field?.inputField.onValueChanged.AddListener((value) => { action(value); }); * } * public static void SetActionOnStringEditorUI_Lock(StringEditorUI field, Action<bool> action) * { * field.OnLockStatusChange += (value) => { action(value); }; * }*/ public static void SetActionOnDropDownSelect(UnityEngine.UI.Dropdown dropDown, Action <int> action) { dropDown?.onValueChanged.RemoveAllListeners(); dropDown?.onValueChanged.AddListener((value) => { action(value); }); }
public virtual void LocalizeText() { if (!started) { return; } // Skip if no language set: if (string.IsNullOrEmpty(PixelCrushers.DialogueSystem.Localization.language)) { return; } if (textTable == null) { textTable = DialogueManager.displaySettings.localizationSettings.textTable; if (textTable == null) { if (DialogueDebug.logWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": No localized text table is assigned to " + name + " or the Dialogue Manager.", this); } return; } } if (!HasCurrentLanguage()) { if (DialogueDebug.logWarnings) { Debug.LogWarning(DialogueDebug.Prefix + "Localized text table '" + textTable + "' does not have a language '" + PixelCrushers.DialogueSystem.Localization.language + "'", this); } return; } // Make sure we have a Text or Dropdown: if (text == null && dropdown == null) { text = GetComponent <UnityEngine.UI.Text>(); dropdown = GetComponent <UnityEngine.UI.Dropdown>(); if (text == null && dropdown == null) { if (DialogueDebug.logWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": LocalizeUIText didn't find a Text or Dropdown component on " + name + ".", this); } return; } } // Get the original values to use as field lookups: if (string.IsNullOrEmpty(fieldName)) { fieldName = (text != null) ? text.text : string.Empty; } if ((fieldNames.Count == 0) && (dropdown != null)) { dropdown.options.ForEach(opt => fieldNames.Add(opt.text)); } // Localize Text: if (text != null) { if (!textTable.HasField(fieldName)) { if (DialogueDebug.logWarnings) { Debug.LogWarning(DialogueDebug.Prefix + ": Localized text table '" + textTable.name + "' does not have a field: " + fieldName, this); } } else { text.text = textTable.GetFieldTextForLanguage(fieldName, Localization.GetCurrentLanguageID(textTable)); } } // Localize Dropdown: if (dropdown != null) { for (int i = 0; i < dropdown.options.Count; i++) { if (i < fieldNames.Count) { dropdown.options[i].text = textTable.GetFieldTextForLanguage(fieldNames[i], Localization.GetCurrentLanguageID(textTable)); } } dropdown.captionText.text = textTable.GetFieldTextForLanguage(fieldNames[dropdown.value], Localization.GetCurrentLanguageID(textTable)); } }
public void Start() { m_DropDown = GetComponent <UnityEngine.UI.Dropdown>(); m_DropDown.onValueChanged.RemoveAllListeners(); m_DropDown.onValueChanged.AddListener(HandleValueChanged); }
public virtual void UpdateText() { if (!started) { return; } if (UILocalizationManager.instance == null) { return; } var textTable = this.textTable; var language = UILocalizationManager.instance.currentLanguage; if (string.IsNullOrEmpty(language)) { return; } // Skip if no language set: if (textTable == null) { Debug.LogWarning("No localized text table is assigned to " + name + " or a UI Localized Manager component.", this); return; } if (!textTable.HasLanguage(language)) { Debug.LogWarning("Text table " + textTable.name + " does not have a language '" + language + "'.", textTable); return; } // Make sure we have a Text or Dropdown: if (text == null && dropdown == null) { text = GetComponent <UnityEngine.UI.Text>(); #if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1) dropdown = GetComponent <UnityEngine.UI.Dropdown>(); #endif if (text == null && dropdown == null) { Debug.LogWarning("Localize UI didn't find a Text or Dropdown component on " + name + ".", this); return; } } // Get the original values to use as field lookups: if (string.IsNullOrEmpty(fieldName)) { fieldName = (text != null) ? text.text : string.Empty; } #if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1) if ((fieldNames.Count == 0) && (dropdown != null)) { dropdown.options.ForEach(opt => fieldNames.Add(opt.text)); } #endif // Localize Text: if (text != null) { if (!textTable.HasField(fieldName)) { Debug.LogWarning("Text table " + textTable.name + " does not have a field '" + fieldName + "'.", textTable); } else { text.text = GetLocalizedText(fieldName); } } #if !(UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1) // Localize Dropdown: if (dropdown != null) { for (int i = 0; i < dropdown.options.Count; i++) { if (i < fieldNames.Count) { dropdown.options[i].text = GetLocalizedText(fieldNames[i]); } } dropdown.captionText.text = GetLocalizedText(fieldNames[dropdown.value]); } #endif }