Created
February 23, 2016 08:30
-
-
Save grimmdev/b052d2dcd2a806808e46 to your computer and use it in GitHub Desktop.
Preferences Utility for Unity 3D and uLiveWallpaper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sean Loper | |
// 2016 | |
// PreferenceUtility.cs | |
using UnityEngine; | |
using System.Globalization; | |
using LostPolygon.uLiveWallpaper; | |
public class PreferenceUtility | |
{ | |
// I had already implemented this way before they even thought of making their own implementation. | |
public static bool Exists(string key) | |
{ | |
return !string.IsNullOrEmpty(LiveWallpaper.Preferences.GetString (key)); | |
} | |
public static bool getBool(string key, string fallback) | |
{ | |
return System.Convert.ToBoolean (LiveWallpaper.Preferences.GetString (key, fallback)); | |
} | |
public static int getInt(string key, string fallback) | |
{ | |
return System.Convert.ToInt32 (LiveWallpaper.Preferences.GetString (key, fallback)); | |
} | |
public static string getString(string key, string fallback) | |
{ | |
return LiveWallpaper.Preferences.GetString (key, fallback); | |
} | |
public static Color getHexColor(string key, string fallback) | |
{ | |
string c = LiveWallpaper.Preferences.GetString (key, fallback); | |
byte r = byte.Parse(c.Substring(1,3), NumberStyles.HexNumber); | |
byte g = byte.Parse(c.Substring(3,2), NumberStyles.HexNumber); | |
byte b = byte.Parse(c.Substring(5,2), NumberStyles.HexNumber); | |
return new Color32(r,g,b, 255); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment