- Home /
Prevent to Deselect InputField
Hello, as far as my last question has been rejected, because of I did not describe it properly, I am creating a new one, hopefully understandable.
Important is that input would be just keyboard. I don't need mouse in this game. I do have simple menu, where user is selecting different stuff like hairstyle and so on. There is no problem with mouse because if user click nothing is happening. But when user come to type in character's name, then the problem come into existence, because there is an InputField and when user click out of InputFieldBox then it is deselected and that is what I need to prevent. What I imagine is user select "Enter your name" with arrows then he hit Enter type there whatever name he wants and then hit enter again for confirmation. Everything is fine until user accidentaly hit leftMouseButton, then he need to go back and select inputField as Active (which is unnecessary).
I have been also asked for some code. I do not have anything important right now, because I want to know if it is even possible. But code might look like.
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class InputFieldName : MonoBehaviour
{
private InputField inputFieldName;
void Start()
{
inputFieldName = gameObject.GetComponent<InputField>();
disableMouseOrSomehowPreventFromDeselecting();
inputField.ActivateInputField();
Cursor.visible = false;
}
private void disableMouseOrSomehowPreventFromDeselecting()
{
//TODO
}
}
Thank you so much for any advice.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Terminal-like GUI, wait for input 1 Answer
Non-Iteractable Input Fields 1 Answer
Multiple Cars not working 1 Answer
Golf Gamelike power bar 1 Answer