InputField.readOnly doesn't work
According to the docs this should work but it doesn't.
http://docs.unity3d.com/ScriptReference/UI.InputField-readOnly.html
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class ReadOnly : MonoBehaviour {
public void Start() {
GetComponent<InputField>().readOnly = true;
}
}
Is it a bug or am I doing something wrong?
Answer by OncaLupe · Dec 17, 2015 at 09:41 AM
You're missing an open curly brace after the class definition (end of line 5). This should give you compile errors and not even let you run the game. If you typed directly into the site, please copy/paste actual code instead. You could have a typo that you didn't put in here.
After adding the curly brace, the code here works fine for me on Unity 5.3.0f4. Make sure it's attached to the object you intend and enabled (checkbox next to the script name on the object). A Debug.Log() would help confirm it's actually running.
Ah that's it, the readOnly property was added in 5.3. I was still on 5.2.3f1