unity3d-gui

How to scroll to a specific element in ScrollRect with Unity UI?

孤街醉人 提交于 2019-12-05 12:02:13
问题 I built a registration form for a mobile game using Unity 5.1. To do that, I use Unity UI components: ScrollRect + Autolayout (Vertical layout) + Text (labels) + Input Field. This part works fine. But, when keyboard is opened, the selected field is under keyboard. Is there a way to programmatically scroll the form to bring the selected field into view? I have tried using ScrollRect.verticalNormalizedPosition and it works fine to scroll some, however I am not able to make selected field appear

How to scroll to a specific element in ScrollRect with Unity UI?

社会主义新天地 提交于 2019-12-04 01:33:51
I built a registration form for a mobile game using Unity 5.1. To do that, I use Unity UI components: ScrollRect + Autolayout (Vertical layout) + Text (labels) + Input Field. This part works fine. But, when keyboard is opened, the selected field is under keyboard. Is there a way to programmatically scroll the form to bring the selected field into view? I have tried using ScrollRect.verticalNormalizedPosition and it works fine to scroll some, however I am not able to make selected field appear where I want. Thanks for your help ! I am going to give you a code snippet of mine because i feel like

4.6 New UI How to change Button Image?

夙愿已清 提交于 2019-11-30 15:35:28
Everything I search is based on the old UI. I've tried the following button.image = Resource.Load<Image>("..."); button.GetComponent<Image>() = Resources.Load<Image>("...."); button.GetComponent<Button>().image = Resources.Load<Image>("...."); button.GetComponent<Image>().sprite = Resources.Load<Sprite>("...."); I want to change the button image on an event. Tested and Working. public Sprite myImage; public Button myBtn; void Start(){ myImage = Resources.Load<Sprite>("BTNS"); // Make sure not to include the file extension //Make sure it is added in the Inspector. Or reference it using

Extending Unity UI components with custom Inspector

流过昼夜 提交于 2019-11-30 14:11:42
Is it possible to extend the new unity ui components like for example the transform component? Because nothing happens when i try to extend the button, instead of the transform component using UnityEditor; using UnityEngine; [CustomEditor(typeof(Transform))] public class CustomTransform : Editor { public override void OnInspectorGUI() { } } Greg Lukosek Yes you can extend UI components and write them their own custom inspector. You just need to remember to use right namespaces and also inherit from the right Inspector class. You can of course override too!. Example here is a

How to get Text from UI.InputField?

試著忘記壹切 提交于 2019-11-28 13:51:31
I want to retrieve the text from a UI InputField but I'm not sure how. You can do it by first getting reference to the gameObject somehow then getting the InputField component from it and taking the component's text variable: GameObject inputFieldGo = GameObject.Find("PathToTheGameObject"); InputField inputFieldCo = inputFieldGo.GetComponent<InputField>(); Debug.Log(inputFieldCo.text); 来源: https://stackoverflow.com/questions/28292841/how-to-get-text-from-ui-inputfield

Get text from Input field in Unity3D with C#

霸气de小男生 提交于 2019-11-28 10:02:38
I'm trying to get a text inside an inputField in Unity3D with C# . I've placed an inputField in my editor, renamed and tagged in: Username_field . My question is: How i can get the text inside the InputField Username_field in a C# script? Attach below monobehaviour script to your InputField gameObject: public class test : MonoBehaviour { void Start () { var input = gameObject.GetComponent<InputField>(); var se= new InputField.SubmitEvent(); se.AddListener(SubmitName); input.onEndEdit = se; //or simply use the line below, //input.onEndEdit.AddListener(SubmitName); // This also works } private

How to get Text from UI.InputField?

六月ゝ 毕业季﹏ 提交于 2019-11-27 07:59:51
问题 I want to retrieve the text from a UI InputField but I'm not sure how. 回答1: You can do it by first getting reference to the gameObject somehow then getting the InputField component from it and taking the component's text variable: GameObject inputFieldGo = GameObject.Find("PathToTheGameObject"); InputField inputFieldCo = inputFieldGo.GetComponent<InputField>(); Debug.Log(inputFieldCo.text); 来源: https://stackoverflow.com/questions/28292841/how-to-get-text-from-ui-inputfield

Get text from Input field in Unity3D with C#

我们两清 提交于 2019-11-27 03:20:56
问题 I'm trying to get a text inside an inputField in Unity3D with C# . I've placed an inputField in my editor, renamed and tagged in: Username_field . My question is: How i can get the text inside the InputField Username_field in a C# script? 回答1: Attach below monobehaviour script to your InputField gameObject: public class test : MonoBehaviour { void Start () { var input = gameObject.GetComponent<InputField>(); var se= new InputField.SubmitEvent(); se.AddListener(SubmitName); input.onEndEdit =