public override void Awake() { base.Awake(); _nvc.Awake(gameObject); _input = GetComponent<UIInput> (); _uiInputField = GetComponent<UnityEngine.UI.InputField>(); }
internal InputField (GameObject parent, bool visible) : base (Addon.Instantiate (parent, "InputField"), visible) { inputField = GameObject.GetComponent<UnityEngine.UI.InputField> (); inputField.onValueChanged.AddListener (x => { Changed = true; }); }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go!=null) { _inputField = _go.GetComponent<UnityEngine.UI.InputField>(); } DoAction(); Finish(); }
public override void OnEnter() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go!=null) { _inputField = go.GetComponent<UnityEngine.UI.InputField>(); if (_inputField!=null) { _inputField.onEndEdit.AddListener(DoOnEndEdit); }else{ LogError("Missing UI.InputField on "+go.name); } }else{ LogError("Missing GameObject"); } }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go!=null) { _inputField = _go.GetComponent<UnityEngine.UI.InputField>(); } if (resetOnExit.Value) { _originalValue = _inputField.placeholder; } DoSetValue(); Finish(); }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go != null) { _inputField = _go.GetComponent <UnityEngine.UI.InputField>(); } if (resetOnExit.Value) { _originalValue = _inputField.shouldHideMobileInput; } DoSetValue(); Finish(); }
int UnityEngineUIInputField_m_OnSubmit(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; UnityEngine.UI.InputField gen_to_be_invoked = (UnityEngine.UI.InputField)translator.FastGetCSObj(L, 1); { UnityEngine.EventSystems.BaseEventData _eventData = (UnityEngine.EventSystems.BaseEventData)translator.GetObject(L, 2, typeof(UnityEngine.EventSystems.BaseEventData)); gen_to_be_invoked.OnSubmit(_eventData); return(0); } }
int UnityEngineUIInputField_m_Rebuild(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; UnityEngine.UI.InputField gen_to_be_invoked = (UnityEngine.UI.InputField)translator.FastGetCSObj(L, 1); { UnityEngine.UI.CanvasUpdate _update; translator.Get(L, 2, out _update); gen_to_be_invoked.Rebuild(_update); return(0); } }
int UnityEngineUIInputField_m_ProcessEvent(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; UnityEngine.UI.InputField gen_to_be_invoked = (UnityEngine.UI.InputField)translator.FastGetCSObj(L, 1); { UnityEngine.Event _e = (UnityEngine.Event)translator.GetObject(L, 2, typeof(UnityEngine.Event)); gen_to_be_invoked.ProcessEvent(_e); return(0); } }
int UnityEngineUIInputField_m_MoveTextStart(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; UnityEngine.UI.InputField gen_to_be_invoked = (UnityEngine.UI.InputField)translator.FastGetCSObj(L, 1); { bool _shift = LuaAPI.lua_toboolean(L, 2); gen_to_be_invoked.MoveTextStart(_shift); return(0); } }
int UnityEngineUIInputField_m_SetTextWithoutNotify(RealStatePtr L, int gen_param_count) { ObjectTranslator translator = this; UnityEngine.UI.InputField gen_to_be_invoked = (UnityEngine.UI.InputField)translator.FastGetCSObj(L, 1); { string _input = LuaAPI.lua_tostring(L, 2); gen_to_be_invoked.SetTextWithoutNotify(_input); return(0); } }
static StackObject *set_text_1(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.String @value = (System.String) typeof(System.String).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.InputField instance_of_this_method = (UnityEngine.UI.InputField) typeof(UnityEngine.UI.InputField).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.text = value; return(__ret); }
/// <summary> /// True if any input element is active. /// </summary> /// <returns></returns> public static bool IsInputInUse() { GameObject selected = EventSystem.current.currentSelectedGameObject; if (selected != null) { UnityEngine.UI.InputField inputField = selected.GetComponent <UnityEngine.UI.InputField>(); if (inputField != null) { return(true); } TMPro.TMP_InputField tmpInputField = selected.GetComponent <TMPro.TMP_InputField>(); if (tmpInputField != null) { return(true); } } return(false); }
void Start() { if (PickPanel == null) PickPanel = this.transform; color0 = PickPanel.Find("colorLast/color0").GetComponent<UnityEngine.UI.RawImage>(); color1 = PickPanel.Find("color1").GetComponent<UnityEngine.UI.RawImage>(); sc = PickPanel.Find("SliderSC").GetComponent<UnityEngine.UI.Slider>(); sr = PickPanel.Find("SliderR").GetComponent<UnityEngine.UI.Slider>(); sg = PickPanel.Find("SliderG").GetComponent<UnityEngine.UI.Slider>(); sb = PickPanel.Find("SliderB").GetComponent<UnityEngine.UI.Slider>(); vr = PickPanel.Find("ValueR").GetComponent<UnityEngine.UI.InputField>(); vg = PickPanel.Find("ValueG").GetComponent<UnityEngine.UI.InputField>(); vb = PickPanel.Find("ValueB").GetComponent<UnityEngine.UI.InputField>(); m = PickPanel.Find("m/Quad"); initPicker(); colorIndexTex = new Texture2D(16, 16, TextureFormat.ARGB32, false); colorIndexTex.filterMode = FilterMode.Point; InitDefPalette(); InitPalette(); }
public IEnumerator MainMenu_to_Forum_with_Tweets() { SceneManager.LoadScene("MainMenu"); yield return(new WaitForSeconds(.001f)); UnityEngine.UI.Button forumButton = GameObject.Find("TheForum").GetComponent <UnityEngine.UI.Button>(); forumButton.onClick.Invoke(); yield return(new WaitForSeconds(.001f)); UnityEngine.UI.InputField TwitterText = GameObject.Find("TwitterText").GetComponent <UnityEngine.UI.InputField>(); TwitterText.text = "Hi!"; UnityEngine.UI.Button TwitterBtn = GameObject.Find("TwitterBtn").GetComponent <UnityEngine.UI.Button>(); TwitterBtn.onClick.Invoke(); yield return(new WaitForSeconds(.001f)); }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go!=null) { _inputField = _go.GetComponent<UnityEngine.UI.InputField>(); } if (resetOnExit.Value) { _originalString = _inputField.text; } DoSetTextValue(); if (!everyFrame) { Finish(); } }
public override void OnEnter() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go!=null) { _inputField = go.GetComponent<UnityEngine.UI.InputField>(); if (_inputField!=null) { #if UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 _inputField.onValueChange.AddListener(DoOnValueChange); #else _inputField.onValueChanged.AddListener(DoOnValueChange); #endif }else{ LogError("Missing UI.InputField on "+go.name); } }else{ LogError("Missing GameObject"); } }
public void ManualSetTextTarget(UnityEngine.UI.Text target) { if (target == null) { previousLinkedGameObject = null; linkedGameObject = null; linkedBehaviour = null; fields.Clear(); field = string.Empty; lastInputField = null; _inputField = null; } else { _inputField = null; lastInputField = null; linkedGameObject = target.gameObject; linkedBehaviour = target; field = "text"; } }
public override void OnEnter() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go != null) { _inputField = go.GetComponent <UnityEngine.UI.InputField>(); if (_inputField != null) { _inputField.onEndEdit.AddListener(DoOnEndEdit); } else { LogError("Missing UI.InputField on " + go.name); } } else { LogError("Missing GameObject"); } }
public override void OnEnter() { GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject); if (_go != null) { _inputField = _go.GetComponent <UnityEngine.UI.InputField>(); } if (resetOnExit.Value) { _originalString = _inputField.text; } DoSetTextValue(); if (!everyFrame) { Finish(); } }
// Get components from the Unity scene private void FindTextComponents() { try { addScoreButton = addScoreButton.GetComponent <UnityEngine.UI.Button>(); status = status.GetComponent <UnityEngine.UI.Text>(); displayScore = displayScore.GetComponent <UnityEngine.UI.Text>(); displayScoreLabel = displayScoreLabel.GetComponent <UnityEngine.UI.Text>(); usernameInput = usernameInput.GetComponent <UnityEngine.UI.InputField>(); score = score.GetComponent <UnityEngine.UI.Text>(); for (int i = 0; i < TOTAL_SCORES; i++) { names[i] = names[i].GetComponent <UnityEngine.UI.Text>(); scores[i] = scores[i].GetComponent <UnityEngine.UI.Text>(); } } catch (System.Exception e) { UnityEngine.Debug.Log(e.Message); } }
/// <summary> /// Write the specified value using the writer. /// </summary> /// <param name="value">Value.</param> /// <param name="writer">Writer.</param> public override void Write(object value, ISaveGameWriter writer) { UnityEngine.UI.InputField inputField = (UnityEngine.UI.InputField)value; writer.WriteProperty("shouldHideMobileInput", inputField.shouldHideMobileInput); writer.WriteProperty("text", inputField.text); writer.WriteProperty("caretBlinkRate", inputField.caretBlinkRate); writer.WriteProperty("caretWidth", inputField.caretWidth); writer.WriteProperty("textComponent", inputField.textComponent); writer.WriteProperty("placeholderType", inputField.placeholder.GetType().AssemblyQualifiedName); writer.WriteProperty("placeholder", inputField.placeholder); writer.WriteProperty("caretColor", inputField.caretColor); writer.WriteProperty("customCaretColor", inputField.customCaretColor); writer.WriteProperty("selectionColor", inputField.selectionColor); writer.WriteProperty("characterLimit", inputField.characterLimit); writer.WriteProperty("contentType", inputField.contentType); writer.WriteProperty("lineType", inputField.lineType); writer.WriteProperty("inputType", inputField.inputType); writer.WriteProperty("keyboardType", inputField.keyboardType); writer.WriteProperty("characterValidation", inputField.characterValidation); writer.WriteProperty("readOnly", inputField.readOnly); writer.WriteProperty("asteriskChar", inputField.asteriskChar); writer.WriteProperty("caretPosition", inputField.caretPosition); writer.WriteProperty("selectionAnchorPosition", inputField.selectionAnchorPosition); writer.WriteProperty("selectionFocusPosition", inputField.selectionFocusPosition); writer.WriteProperty("navigation", inputField.navigation); writer.WriteProperty("transition", inputField.transition); writer.WriteProperty("colors", inputField.colors); writer.WriteProperty("spriteState", inputField.spriteState); writer.WriteProperty("animationTriggers", inputField.animationTriggers); writer.WriteProperty("targetGraphicType", inputField.targetGraphic.GetType().AssemblyQualifiedName); writer.WriteProperty("targetGraphic", inputField.targetGraphic); writer.WriteProperty("interactable", inputField.interactable); writer.WriteProperty("image", inputField.image); writer.WriteProperty("useGUILayout", inputField.useGUILayout); writer.WriteProperty("enabled", inputField.enabled); writer.WriteProperty("tag", inputField.tag); writer.WriteProperty("name", inputField.name); writer.WriteProperty("hideFlags", inputField.hideFlags); }
/// <summary> /// Targets the indicated input field for the keyboard. This will also 'select' the InputField in Unity UI /// </summary> /// <param name="target"></param> public void SetInputTarget(TMPro.TMP_InputField target) { if (!ValidateHost()) { return; } _tmpInputField = target; _inputField = null; if (_tmpInputField != null) { _tmpInputField.Select(); LastTMProInputField = _tmpInputField; if (_tmpInputField.selectionAnchorPosition > _tmpInputField.selectionFocusPosition) { insertPoint = _tmpInputField.selectionFocusPosition; selectionLength = _tmpInputField.selectionAnchorPosition - _tmpInputField.selectionFocusPosition; } else if (_tmpInputField.selectionFocusPosition > _tmpInputField.selectionAnchorPosition) { insertPoint = _tmpInputField.selectionAnchorPosition; selectionLength = _tmpInputField.selectionFocusPosition - _tmpInputField.selectionAnchorPosition; } else { insertPoint = _tmpInputField.selectionAnchorPosition; selectionLength = 0; } } if (_tmpInputField != null && EventSystem.current.currentSelectedGameObject != linkedGameObject) { LastTMProInputField = _tmpInputField; linkedGameObject = EventSystem.current.currentSelectedGameObject; linkedBehaviour = LastTMProInputField; field = "text"; } }
/// <summary> /// Targets the indicated input field for the keyboard. This will also 'select' the InputField in Unity UI /// </summary> /// <param name="target"></param> public void SetInputTarget(UnityEngine.UI.InputField target) { if (!ValidateHost()) { return; } _inputField = target; _tmpInputField = null; if (_inputField != null) { _inputField.Select(); lastInputField = _inputField; if (_inputField.selectionAnchorPosition > _inputField.selectionFocusPosition) { insertPoint = _inputField.selectionFocusPosition; selectionLength = _inputField.selectionAnchorPosition - _inputField.selectionFocusPosition; } else if (_inputField.selectionFocusPosition > _inputField.selectionAnchorPosition) { insertPoint = _inputField.selectionAnchorPosition; selectionLength = _inputField.selectionFocusPosition - _inputField.selectionAnchorPosition; } else { insertPoint = _inputField.selectionAnchorPosition; selectionLength = 0; } } if (_inputField != null && EventSystem.current.currentSelectedGameObject != linkedGameObject) { lastInputField = _inputField; linkedGameObject = EventSystem.current.currentSelectedGameObject; linkedBehaviour = lastInputField; field = "text"; } }
public UGUINode DrawLayer(GroupNode layer, UGUINode parent) { UGUINode node = PSDImportUtility.InstantiateItem(GroupType.INPUTFIELD, layer.Name, parent); UnityEngine.UI.InputField inputfield = node.InitComponent <UnityEngine.UI.InputField>(); if (layer.images != null) { for (int imageIndex = 0; imageIndex < layer.images.Count; imageIndex++) { ImgNode image = layer.images[imageIndex]; string lowerName = image.Name.ToLower(); if (image.type == ImgType.Label) { if (lowerName.StartsWith("t_")) { UnityEngine.UI.Text text = (UnityEngine.UI.Text)inputfield.textComponent;//inputfield.transform.Find("Text").GetComponent<UnityEngine.UI.Text>(); PSDImportUtility.SetPictureOrLoadColor(image, text); } else if (lowerName.StartsWith("p_")) { UnityEngine.UI.Text text = (UnityEngine.UI.Text)inputfield.placeholder;//.transform.Find("Placeholder").GetComponent<UnityEngine.UI.Text>(); PSDImportUtility.SetPictureOrLoadColor(image, text); } } else { if (lowerName.StartsWith("b_")) { PSDImportUtility.SetPictureOrLoadColor(image, inputfield.image); PSDImportUtility.SetRectTransform(image, inputfield.GetComponent <RectTransform>()); } } } } return(node); }
public IEnumerator Submit_MCQ_Questions() { SceneManager.LoadScene("MainMenu"); yield return(null); UnityEngine.UI.Button MCQButton = GameObject.Find("SubmitMCQ").GetComponent <UnityEngine.UI.Button>(); MCQButton.onClick.Invoke(); yield return(new WaitForSeconds(.001f)); UnityEngine.UI.InputField QuestionBody = GameObject.Find("QuestionBody").GetComponent <UnityEngine.UI.InputField>(); QuestionBody.text = "This is a new question!"; UnityEngine.UI.InputField ChoiceA = GameObject.Find("ChoiceA").GetComponent <UnityEngine.UI.InputField>(); ChoiceA.text = "Answer A"; UnityEngine.UI.InputField ChoiceB = GameObject.Find("ChoiceB").GetComponent <UnityEngine.UI.InputField>(); ChoiceB.text = "Answer B"; UnityEngine.UI.InputField ChoiceC = GameObject.Find("ChoiceC").GetComponent <UnityEngine.UI.InputField>(); ChoiceC.text = "Answer C"; UnityEngine.UI.InputField ChoiceD = GameObject.Find("ChoiceD").GetComponent <UnityEngine.UI.InputField>(); ChoiceD.text = "Answer D"; UnityEngine.UI.Button SubmitBtn = GameObject.Find("SubmitButton").GetComponent <UnityEngine.UI.Button>(); SubmitBtn.onClick.Invoke(); yield return(new WaitForSeconds(.001f)); yield return(null); }
void Start() { LoadOrSaveState loadOrSaveState = (LoadOrSaveState)StateHolder.StateManager.GetAndClearPassedState(); mSaveScreenMode = loadOrSaveState.mSaveScreenMode; mReturnScene = loadOrSaveState.mReturnScene; mSaveNameInputField = mTextbox.GetComponent <UnityEngine.UI.InputField>(); int saveVersion = 0; for (SaveSlot slot = SaveSlot.One; slot <= SaveSlot.Max; slot++) { int slotIndex = (int)slot - 1; if (SaveManager.ReadSaveHeader(slot, out saveVersion, ref mSaveNames[slotIndex])) { mSaveSlotButtons[slotIndex].GetComponent <UnityEngine.UI.Button>().interactable = true; mSaveSlotButtons[slotIndex].GetComponentInChildren <UnityEngine.UI.Text>().text = "Slot " + ((int)slot).ToString() + ": " + mSaveNames[slotIndex]; } else { mSaveSlotButtons[slotIndex].GetComponent <UnityEngine.UI.Button>().interactable = mSaveScreenMode != SaveScreenMode.Loading; mSaveSlotButtons[slotIndex].GetComponentInChildren <UnityEngine.UI.Text>().text = "Slot " + ((int)slot).ToString() + (mSaveScreenMode == SaveScreenMode.Loading ? ": no valid save" : ": no save"); } } if (mSaveScreenMode == SaveScreenMode.Loading) { mSaveNameInputField.interactable = false; } UpdateUI(); }
/** 初期化。 */ public void Initialize(InputField2D a_parent) { //raw this.raw_gameobject = Fee.Instantiate.Instantiate.CreateUiInputField("InputField", Fee.Render2D.Render2D.GetInstance().GetRootTransform()); this.raw_focus_monobehaviour = this.raw_gameobject.AddComponent <Fee.Ui.Focus_MonoBehaviour>(); this.raw_transform = this.raw_gameobject.GetComponent <UnityEngine.Transform>(); this.raw_inputfield = this.raw_gameobject.GetComponent <UnityEngine.UI.InputField>(); this.raw_recttransform = this.raw_gameobject.GetComponent <UnityEngine.RectTransform>(); this.raw_text = this.raw_inputfield.textComponent; this.raw_image = this.raw_inputfield.image; this.raw_placeholder_text = this.raw_inputfield.placeholder.GetComponent <UnityEngine.UI.Text>(); this.raw_gameobject.SetActive(false); { UnityEngine.UI.Navigation t_navigation = this.raw_inputfield.navigation; t_navigation.mode = UnityEngine.UI.Navigation.Mode.None; this.raw_inputfield.navigation = t_navigation; } //共通マテリアルアイテム複製。 this.raw_custom_text_material_item = Render2D.GetInstance().GetUiTextMaterialItem().DuplicateMaterialItem(); this.raw_custom_image_material_item = Render2D.GetInstance().GetUiImageMaterialItem().DuplicateMaterialItem(); }
private void Awake() { hostInputField = GetComponent <UnityEngine.UI.InputField>(); if (initalizeMode == UixSyncInitializationMode.MatchVariable && textVariable != null) { internalUpdate = true; hostInputField.text = textVariable.Value; internalUpdate = false; } else if (initalizeMode == UixSyncInitializationMode.MatchUiControl && textVariable != null) { internalUpdate = true; textVariable.Value = hostInputField.text; internalUpdate = false; } hostInputField.onValueChanged.AddListener(HandleChange); hostInputField.onEndEdit.AddListener(HandleEndEdit); }
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 SetActionOnInputField(UnityEngine.UI.InputField field, Action <string> action) { field?.onValueChanged.RemoveAllListeners(); field?.onValueChanged.AddListener((value) => { action(value); }); }
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(); }
private void Start() { field = GetComponent <UnityEngine.UI.InputField>(); field.onValueChanged.AddListener(ParseAll); }
protected void _Create(EleBaseRect parent, string text, Font font, Color fontColor, int pointSize, bool multiline, Sprite plate, PadRect padding, Vector2 size, string name) { this.border = padding; GameObject go = new GameObject("InputPlate_" + name); go.transform.SetParent(parent.GetContentRect(), false); go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; UnityEngine.UI.Image img = go.AddComponent <UnityEngine.UI.Image>(); img.RTQ().TopLeftAnchorsPivot(); img.sprite = plate; img.type = UnityEngine.UI.Image.Type.Sliced; GameObject goInput = new GameObject("Input_" + name); goInput.transform.SetParent(go.transform, false); this.rtInput = goInput.AddComponent <RectTransform>(); this.rtInput.pivot = new Vector2(0.0f, 1.0f); this.rtInput.anchorMin = Vector2.zero; this.rtInput.anchorMax = Vector2.one; this.rtInput.offsetMin = new Vector2(padding.left, padding.bot); this.rtInput.offsetMax = new Vector2(-padding.right, -padding.top); GameObject goText = new GameObject("InputText_" + name); goText.transform.SetParent(this.rtInput, false); goText.transform.localRotation = Quaternion.identity; goText.transform.localPosition = Vector3.zero; UnityEngine.UI.Text txt = goText.AddComponent <UnityEngine.UI.Text>(); txt.RTQ().TopLeftAnchorsPivot().ExpandParentFlush(); GameObject goPlaceholder = new GameObject("InputPlaceholder_" + name); goPlaceholder.transform.SetParent(this.rtInput, false); goPlaceholder.transform.localRotation = Quaternion.identity; goPlaceholder.transform.localPosition = Vector3.zero; UnityEngine.UI.Text txtPlace = goPlaceholder.AddComponent <UnityEngine.UI.Text>(); txtPlace.RTQ().TopLeftAnchorsPivot().ExpandParentFlush(); this.input = goInput.AddComponent <UnityEngine.UI.InputField>(); this.input.textComponent = txt; this.input.targetGraphic = img; this.input.placeholder = txtPlace; this.rt = go.GetComponent <RectTransform>(); this.placeholder = txtPlace; this.text = txt; this.text.color = fontColor; this.text.font = font; this.text.fontSize = pointSize; this.text.verticalOverflow = VerticalWrapMode.Overflow; this.placeholder.color = new Color(fontColor.r, fontColor.g, fontColor.b, fontColor.a * 0.5f); this.placeholder.font = font; this.placeholder.fontSize = pointSize; this.placeholder.verticalOverflow = VerticalWrapMode.Overflow; this.input.lineType = multiline ? UnityEngine.UI.InputField.LineType.MultiLineNewline : UnityEngine.UI.InputField.LineType.SingleLine; if (multiline == false) { this.text.alignment = TextAnchor.MiddleLeft; this.placeholder.alignment = TextAnchor.MiddleLeft; } }
protected override void OnInit() { base.OnInit(); input = GetComponent <UnityEngine.UI.InputField>(); }
public void DrawLayer(Layer layer, GameObject parent) { UnityEngine.UI.InputField temp = AssetDatabase.LoadAssetAtPath(PSDImporterConst.ASSET_PATH_INPUTFIELD, typeof(UnityEngine.UI.InputField)) as UnityEngine.UI.InputField; UnityEngine.UI.InputField inputfield = GameObject.Instantiate(temp) as UnityEngine.UI.InputField; inputfield.transform.SetParent(parent.transform, false);//.parent = parent.transform; inputfield.name = layer.name; inputfield.placeholder?.gameObject.SetActive(false); //if (layer.image != null) if (layer.layers != null) { for (int imageIndex = 0; imageIndex < layer.layers.Length; imageIndex++) { PSImage image = layer.layers[imageIndex].image; //PSImage image = layer.image; if (image.imageType == ImageType.Label) { if (image.name.ToLower().Contains("text")) { UnityEngine.UI.Text text = (UnityEngine.UI.Text)inputfield.textComponent;//inputfield.transform.Find("Text").GetComponent<UnityEngine.UI.Text>(); Color color; if (UnityEngine.ColorUtility.TryParseHtmlString(("#" + image.arguments[0]), out color)) { text.color = color; } int size; float sizeFloat; if (float.TryParse(image.arguments[2], out sizeFloat)) { size = Mathf.RoundToInt(sizeFloat); text.fontSize = size; } text.text = image.arguments[3]; //设置字体,注意unity中的字体名需要和导出的xml中的一致 string fontFolder; if (image.arguments[1].ToLower().Contains("static")) { fontFolder = PSDImporterConst.FONT_STATIC_FOLDER; } else { fontFolder = fontFolder = PSDImporterConst.FONT_FOLDER; } string fontFullName = fontFolder + image.arguments[1] + PSDImporterConst.FONT_SUFIX; Debug.Log("font name ; " + fontFullName); var font = AssetDatabase.LoadAssetAtPath(fontFullName, typeof(Font)) as Font; if (font == null) { Debug.LogWarning("Load font failed : " + fontFullName); } else { text.font = font; } //ps的size在unity里面太小,文本会显示不出来,暂时选择溢出 text.verticalOverflow = VerticalWrapMode.Overflow; text.horizontalOverflow = HorizontalWrapMode.Overflow; //设置对齐 if (image.arguments.Length >= 5) { text.alignment = ParseAlignmentPS2UGUI(image.arguments[4]); } else { text.alignment = TextAnchor.MiddleLeft; } TextImport.SetOutline(image, text); } else if (image.name.ToLower().Contains("holder")) { /* * UnityEngine.UI.Text text = (UnityEngine.UI.Text)inputfield.placeholder;//.transform.Find("Placeholder").GetComponent<UnityEngine.UI.Text>(); * Color color; * if (UnityEngine.ColorUtility.TryParseHtmlString(("#" + image.arguments[0]), out color)) * { * text.color = color; * } * * int size; * float sizeFloat; * if (float.TryParse(image.arguments[2], out sizeFloat)) * { * size = Mathf.RoundToInt(sizeFloat); * text.fontSize = size; * } * * text.text = image.arguments[3]; * * //设置字体,注意unity中的字体名需要和导出的xml中的一致 * string fontFolder; * * if (image.arguments[1].ToLower().Contains("static")) * { * fontFolder = PSDImporterConst.FONT_STATIC_FOLDER; * } * else * { * fontFolder = fontFolder = PSDImporterConst.FONT_FOLDER; * } * string fontFullName = fontFolder + image.arguments[1] + PSDImporterConst.FONT_SUFIX; * Debug.Log("font name ; " + fontFullName); * var font = AssetDatabase.LoadAssetAtPath(fontFullName, typeof(Font)) as Font; * if (font == null) * { * Debug.LogWarning("Load font failed : " + fontFullName); * } * else * { * text.font = font; * } * //ps的size在unity里面太小,文本会显示不出来,暂时选择溢出 * text.verticalOverflow = VerticalWrapMode.Overflow; * text.horizontalOverflow = HorizontalWrapMode.Overflow; * //设置对齐 * if (image.arguments.Length >= 5) * text.alignment = ParseAlignmentPS2UGUI(image.arguments[4]); * else * { * text.alignment = TextAnchor.MiddleLeft; * }*/ } } else { if (image.name.ToLower().Contains("background")) { if (image.imageSource == ImageSource.Common || image.imageSource == ImageSource.Custom) { string assetPath = PSDImportUtility.baseDirectory + image.name + PSDImporterConst.PNG_SUFFIX; Sprite sprite = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Sprite)) as Sprite; inputfield.image.sprite = sprite; RectTransform rectTransform = inputfield.GetComponent <RectTransform>(); rectTransform.sizeDelta = new Vector2(image.size.width, image.size.height); rectTransform.anchoredPosition = new Vector2(image.position.x, image.position.y); } else if (image.imageSource == ImageSource.Global) { SpriteImport.SetGlobalImage(inputfield.image, image); } } } } } }
// Use this for initialization void Start() { input = gameObject.transform.GetComponent<UnityEngine.UI.InputField> (); input.onEndEdit.AddListener (OnLine); Focus (); }
public void PlayAudioFile(UnityEngine.UI.InputField FileNameIN, System.TimeSpan?OffsetStart) { PlayAudioStream(FileNameIN.text, OffsetStart); }
void InitInput(GameObject windows) { GameObject input_obj = new GameObject("input"); input_obj.transform.parent = windows.transform; UnityEngine.UI.Image img_input = input_obj.AddComponent<UnityEngine.UI.Image>(); img_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); img_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, -15, 30); img_input.rectTransform.anchorMin = new Vector2(0, 0.3f); img_input.rectTransform.anchorMax = new Vector2(1, 0.3f); img_input.rectTransform.pivot = new Vector2(0f, 0f); img_input.color = new Color(0, 0, 0, 1); GameObject input_placeholder = new GameObject("placeHolder"); input_placeholder.transform.parent = input_obj.transform; UnityEngine.UI.Text text_holder = input_placeholder.AddComponent<UnityEngine.UI.Text>(); text_holder.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); text_holder.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5, -10); text_holder.rectTransform.anchorMin = new Vector2(0, 0); text_holder.rectTransform.anchorMax = new Vector2(1, 1); text_holder.rectTransform.pivot = new Vector2(0.5f, 0.5f); text_holder.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_holder.color = Color.grey; text_holder.text = ">"; GameObject input_page = new GameObject("pageamount"); input_page.transform.parent = input_obj.transform; text_pageCount = input_page.AddComponent<UnityEngine.UI.Text>(); text_pageCount.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 0); text_pageCount.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5, -10); text_pageCount.rectTransform.anchorMin = new Vector2(0, 0); text_pageCount.rectTransform.anchorMax = new Vector2(1, 1); text_pageCount.rectTransform.pivot = new Vector2(0.5f, 0.5f); text_pageCount.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_pageCount.color = Color.grey; text_pageCount.text = currentPersent + "%"; text_pageCount.alignment = TextAnchor.MiddleRight; GameObject input_text_obj = new GameObject("inputText"); input_text_obj.transform.parent = input_obj.transform; UnityEngine.UI.Text text_input = input_text_obj.AddComponent<UnityEngine.UI.Text>(); text_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 10, -20); text_input.rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 5, -10); text_input.rectTransform.anchorMin = new Vector2(0, 0); text_input.rectTransform.anchorMax = new Vector2(1, 1); text_input.rectTransform.pivot = new Vector2(0.5f, 0.5f); text_input.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; text_input.color = Color.white; text_input.supportRichText = false; input = input_obj.AddComponent<UnityEngine.UI.InputField>(); input.textComponent = text_input; //input.placeholder = text_holder; //input.ActivateInputField(); ///Init event input.onEndEdit.AddListener(ProcessInput); }
void Start() { mTextField = GetComponent <UnityEngine.UI.InputField>(); voice = new SpVoice(); }