- Home /
Scriptable Object only useable from code, not via inspector
Hello everyone,
I have a rather simple Scriptable Object which looks like this:
What works is that I can change the values from within my code and they are saved and used as expected.
However, what does not work anymore is that the values shown in the inspector do not change if the values are changed within the code and the other way round: If I change the values in the inspector during runtime this has no effect.
Can somebody tell me what goes wrong?
Extra question (but above is way more important): Visual Studio tells me that the gameHasEnded variable is "assignd but never used" (see first screenshot). However, below you see that it has 3 references and it is used. I did not figure out how to get rid of it.
Answer by Hellium · May 02, 2021 at 05:49 PM
Are you sure you reference the same scriptable object?
However, below you see that it has 3 references and it is used
No they aren't. The properties you have are auto properties and don't use the private field. This is most likely the source of your main problem BTW.
public bool NewLevelLoaded
{
get => newLevelLoaded;
set => newLevelLoaded = value;
}
Note that this kind of property is almost useless. a direct public field would do the exact same job.
oh yes, I see... I read about these auto properties but assumed that they are only generated if no private fields are defined. Obviously, this is not the case ;-)
Thanks a lot for your help! At the end the solution is very easy if you know the reason :-)
Your answer
Follow this Question
Related Questions
Show multiple attached scripts variables in one script in the inspector 0 Answers
Replicate "Apply" and "Revert" button functionality in ScriptableObject Editor Inspector 2 Answers
Showing scriptable object and bool within that object in inspector. 0 Answers
HeaderAttribute [Header()] on ScriptableObject not working? 2 Answers
On quest for generic editor to allow inspectability and testability of plain data classes 1 Answer