0

This seems like a pretty basic error but I can't get to solve this for some reason... So here it is : I have a settings page with a Slider and a SettingsHandler gameObject with a script attached. This script has a public Slider variable, which means I can drag and drop the slider to link it.

Now, for some reason, when I actually run that settings page, it shows me the following error : error message

extra code screenshots related to the error : Slider variable, Error line, Script variables shown in Unity

(sorry for the images as links, I have no idea how to make them show easily)

Edit : forgot to mention that the slider somehow works when testing and the Text variable changes and actually gets its value updated

Plix6
  • 3
  • 2
  • Does this answer your question? [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – shingo Mar 29 '23 at 04:13
  • @shingo not really, but you made me realize that I forgot to put some important info in the question The things is the console keeps telling me I have that error but in practice, the slider in itself works fine... – Plix6 Mar 29 '23 at 04:25

1 Answers1

0

On your screenshots, all seems fine. There are several options:

  • Check that this is the only instance of your script in the scene. Perhaps, there is another instance without the gridSizeSlider value being set. You can check it fast by entering t: SettingsController in the scene hierarchy search field. It will show all the objects with this script attached.
  • Check if you set your gridSizeSlider value somewhere. Perhaps, it is set to null after initialization.
Morion
  • 10,495
  • 1
  • 24
  • 33
  • Damn good idea, I actually had another object that had the script attached to it and didn't notice it. Thanks a lot ! – Plix6 Mar 29 '23 at 05:26