- Home /
ScriptableSingleton inspector is disabled
I have a ScriptableSingleton which looks something like this:
[FilePath("myFilePath.asset", FilePathAttribute.Location.ProjectFolder)]
public class PlayerSingleSCO : ScriptableSingleton<PlayerSingleSCO>
{
public float jumpHeight = 1f;
public void SaveSettings()
{
Save(true);
}
}
I would like like to edit my instance of this class with something like the default inspector window, and I don't want to have to add to a custom editor class every time I change the ScriptableSingleton class.
I have tried many things, including the following:
public class SCOEditor : EditorWindow
{
Editor editor;
void OnGUI()
{
editor ??= Editor.CreateEditor(PlayerSingleSCO.instance);
editor.OnInspectorGUI();
}
}
This successfully creates fields for my class in an editor window, however, those fields are all disabled making editing impossible. I tried setting GUI.enabled to true but that does nothing. I have also tried:
var iter = new SerializedObject(PlayerSingleSCO.instance).GetIterator();
while (iter.Next(true))
{
EditorGUILayout.PropertyField(iter);
}
This also creates fields for the class, in addition to several fields I don't need (probably from the base class), but they're all disabled as well.
Can anyone help me with why these fields are disabled, or if there is an easier way to accomplish editing a ScriptableSingleton without going through the trouble of manually creating fields for every single Singleton in my project?
Your answer
Follow this Question
Related Questions
Custom Inspector for ScriptableObject 1 Answer
Unity inspector scripting - scriptable objects - card game 0 Answers
How to set Inspector veiw for Hierarchy view vs Project view. 0 Answers
Editor: How to save changes to a ScriptableObject loaded from Resources? 1 Answer
On quest for generic editor to allow inspectability and testability of plain data classes 1 Answer