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?
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.