Using PlayerPrefsController

Hi

I’m not sure how the Options Controller and Music Player are able to access the PlayerPrefsController file. I was under the impression that a script had to be attached to a gameobject as a component and then could only be accessed by using the “FindObjectOfType” method.

Hi @childekrypton,

Welcome to our community! :slight_smile:

The methods in the PlayerPrefsController class are static. Static things in C# do not need an object. You can access them directly. The disadvantage is that they cannot access anything that is non-static, for example, no objects in the Unity scene. The PlayerPrefs are static, though.

Did this clear it up for you?


See also:

Great! Yeah thanks it did!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms