- Home /
Editor Window: Renaming an object using SerializedProperty
Hi. I'm new to using the SerializedObject way of working with editor windows, and I feel like I must be missing something very obvious, but I can't seem to figure out how to change certain inherited serialized properties such as the name of the object, using a PropertyField . I can use other SerializedProperties I add to the class itself, but using "ser_compartment.FindProperty("name")" throws a null error. I couldn't get "MonoBehavior.name" or "Object.name" to work, either, as I'd assume the object name must be stored in there somewhere. I'd heard that "m_Name" might work, and while it does stop the null reference errors from happening, AND gets serialized when the field is modified, all the objects I try it on start with a blank string for the m_Name, and changing it doesn't ever update the name in the Inspector, so I feel like that must be some other name property I probably shouldn't be touching...
Could someone please point out to me how I'd change things like this (object name), or other things like transform, position and rotatation? (basically, any other properties I'd normally have direct access to in a monobehavior.) Is there any place where all the properties of things like MonoBehaviors are listed, for future reference? Thanks :)
Oh, I'm just trying to use something simple like:
SerializedProperty ser_name = ser_compartment.FindProperty("name");
EditorGUI.PropertyField(newPos, ser_name);
ser_compartment.ApplyModifiedProperties();
(ser_Compartment is a SerializedObject, and is NOT the one throwing the null exception; I double checked. Works with other, private properties)
Your answer
Follow this Question
Related Questions
Replicate "Apply" and "Revert" button functionality in ScriptableObject Editor Inspector 2 Answers
Dynamic serialized fields based on enum 0 Answers
Setting the m_PrefabInternal property using the SeriailizedProperty System 0 Answers
How can I use a GUIStyle in a Custom Editor which is set within that Custom Editor? 1 Answer
Mass component editing through SerializedProperty or Setters 0 Answers