- Home /
Avoid Base Values being public via Custom Inspector
Hi guys,
First: Sorry for my bad english ^.^
I am editing the base values for my Player's hitpoints via the Standard Inspector. But by doing this, I have a lot of public values that i do NOT want to have public!
They are not going to be modified in any situation. So I want them to have the innermost scope they could have. Best would be private/const/readonly etc.
Is there any way to edit private values via a Custom Inspector, because I really dont want them to be modify-able.
I hope you all understood me :)
greetz
Answer by whydoidoit · Jul 19, 2012 at 10:46 AM
Yes if you write a custom inspector and make some function or property to set those values you would be able to have them as private (but not const or readonly) - but that function will still exist so they could be set by it when called by another piece of the code.
Thanks for your answer.
I tried this:
using UnityEditor; using UnityEngine; using System.Collections; [CustomEditor(typeof($$anonymous$$ob))] public class $$anonymous$$obInspector : Editor { void OnInspectorGUI() { GUILayout.Label("This is a Label in a Custom Editor"); } }
but it does not seem to work. I don't see any label, when I inspect my $$anonymous$$ob Script that is attached to a gameobject.
Can you give me a short introduction maybe?