- Home /
Setting an inputfield to inactive until a button activates it?
Hello, I'm very new to unity and am struggling with this. What I am trying to do is have an input field object's .SetActive to be false until it is set true by the OnClick event from a button. After the user has pressed enter or unfocused the input field, I would like the .SetActive to be back to false. I know how to get a button to alter the status of the input field, I just don't know how to set an input field inactive at the times when the button isn't clicked since it is defaulted to being active. Thank you in advance to anyone who replies!
Answer by cfalonzo · Dec 02, 2020 at 07:11 AM
Ok I actually found a video that shows how to make the inputfield hidden by default. I'll link it with a timestamp. https://youtu.be/4n6RT805rCc?t=275 The inputfield is now hidden by default and will appear when I press a button. However, I still cannot figure out how to make it so it is hidden again once a different button is clicked/the user clicks somewhere else on the screen.
Figured it out. I accidentally overlooked the fact that inputfield's have an On End Edit event you can mess with in the inspector. I just call this method from my inputfield's script when the OnEndEdit event happens..
Answer by _DS_1 · Dec 03, 2020 at 01:37 AM
Maybe this will help you: https://answers.unity.com/questions/947856/how-to-detect-click-outside-ui-panel.html
Your answer
Follow this Question
Related Questions
How to reactivate items ? 4 Answers
Unity 3D: How to make the gameobject speed increase continuously on tapping quickly? 1 Answer
Simple GameObject Hide/Unhide with bool!!! 0 Answers
Script is giving error that no MonoBehaviour scripts in file 0 Answers
How to double spirte/gameobject/prefab and control the result on those items? 0 Answers