-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Options System using PlayerPrefs #71
Conversation
public class AudioOptions | ||
{ | ||
[Option("Master")] | ||
public float master { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upper case public properties.
[Option("SFX")] | ||
public float sfx { get; set; } | ||
|
||
public void Print() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either use Log.Debug
as it is functionally more complete than Debug.Log
.
Initialize(); | ||
GetDataFromPrefs(); | ||
var audio = Get<AudioOptions>(); | ||
audio.Print(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These value initialization should go in the individual Options classes themselves.
public class OptionCategory : Attribute { | ||
private string name; | ||
public OptionCategory(string name) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use K&R style bracing. We may want to set up a style-guide for Hourai Teahouse as a whole.
select t; | ||
|
||
StringBuilder allPropertiesStr = new StringBuilder(); | ||
foreach (var t in q) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use single letter variable names in foreach loops.
|
||
T Get<T>() | ||
{ | ||
object obj = optionObjs[typeof(T)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use TryGetValue
here instead.
|
||
foreach (var p in t.GetProperties()) | ||
{ | ||
StringBuilder keyStr = new StringBuilder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For short strings, use string interpolation via string.Format
or just normal concatenation. StringBuilder is more suited for long complex strings.
2. Removed type data from PlayerPref values
…ading data in registry
Prefs logs loading of PlayerPrefs and supports more types.
This is mostly ready, mainly missing two things:
|
Implements #48.
An attempt on reflection-based Option System.