You Can See It, But Never Touch It
When you start using Unity, the first type of “customizable controls” you learn to make, probably involve having a bunch of public variables to tweak during run-time to test.
We all start like that, but if you work a little longer on a project you might realize, that you make some things public just to reference them in another script, NOT to edit them on the inspector.
For example, if at runtime you get a reference to some component to cache it, you might not need the inspector to allow to change it, but you would want to see it anyway to see that it is working as intended.
This little tool was developed with those occasions in mind.
Once the attribute has been installed in your project, you can now place the attribute on top of any serialized field to have it permanently “locked” but view-able in your inspector:
[ReadOnly] public string myString; [ReadOnly] [SerializeField] private string _myOtherString;
Just keep in mind that this tool only works on fields, and that will not lock things in a DEBUG inspector. But if you don’t mind that (as they are minor pet-peeves more than anything), enjoy~
You just read about one of several FREE tools that you can get on the Unity Development Tools Repository. Again, they are FREE so just go see them, there are neat things in there~See all of the tools!
Hope you find a good use for this tool as I have. It is always present on my projects.
This concludes today’s post, short but sweet.
But Like Always…
Thank you very much for reading my blog :3
Do you make games? Then I got something for you.
Given how you are reading about Unity tools, just wanted to extend you an invitation to subscribe to the GAME DEVELOPER newsletter for FREE.
Don’t worry, you will ONLY receive notifications on game development content, which include helpful game development tutorials, tips and tricks, and updated on new FREE dev tools directly on your inbox.