void Awake() { // Prevent multiple instances of Lumos from existing. // Necessary because DontDestroyOnLoad keeps the object between scenes. if (instance != null) { LumosUnity.Debug.Log("Destroying duplicate game object instance."); Destroy(gameObject); return; } credentials = LumosCredentials.Load(); if (credentials == null || credentials.apiKey == null || credentials.apiKey == "") { LumosUnity.Debug.LogError("The Lumos API key is not set. Do this in the Lumos pane in Unity's preferences.", true); Destroy(gameObject); return; } instance = this; // Shorten the timer interval while developers are testing if (runWhileInEditor && Application.isEditor) { timerInterval = 3; } DontDestroyOnLoad(this); }
void OnEnable() { credentials = LumosCredentialsManager.GetCredentials(); if (LumosPackages.package == LumosPackages.Update.None || LumosPackages.package == LumosPackages.Update.CheckingVersion) { LumosPackages.CheckForUpdates(); } }
void CheckLumosInstall() { var credentials = LumosCredentials.Load(); if (credentials.apiKey.Length != 36) { errorMessage = apiKeyMissing; } }
public static void PreferencesGUI() { if (!prefsLoaded) { prefsLoaded = true; credentials = LumosCredentialsManager.GetCredentials(); LumosPackages.CheckForUpdates(); } // General settings. GUILayout.Label("General", EditorStyles.boldLabel); EditorGUILayout.LabelField("Version", Lumos.version); credentials.apiKey = EditorGUILayout.TextField(apiKeyLabel, credentials.apiKey); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent("Run Setup Scripts", "Attaches required powerup scripts to the Lumos GameObject. Click this if you subscribed to new powerups since first installing Lumos."), GUILayout.Width(Screen.width / 2.9f))) { LumosPackages.RunSetupScripts(); } GUILayout.EndHorizontal(); EditorGUILayout.Space(); // Checking for updates GUILayout.Label("Updates", EditorStyles.boldLabel); switch (LumosPackages.package) { case LumosPackages.Update.CheckingVersion: GUILayout.Label("Checking for updates..."); break; case LumosPackages.Update.OutOfDate: GUILayout.Label("An update is available."); EditorGUILayout.Space(); if (GUILayout.Button("Download Lumos " + LumosPackages.latestVersion, GUILayout.Width(Screen.width / 3))) { Application.OpenURL("https://www.lumospowered.com/downloads"); } break; case LumosPackages.Update.UpToDate: GUILayout.Label("You are up to date!"); break; } EditorGUILayout.Space(); // Save changed preferences. if (GUI.changed) { EditorUtility.SetDirty(credentials); } }
/// <summary> /// Gets the user's Lumos credentials, creating a new object if necessary. /// </summary> /// <returns>Lumos credentials.</returns> public static LumosCredentials GetCredentials() { if (credentials == null) { credentials = LumosCredentials.Load(); if (credentials == null) { credentials = CreateCredentials(); } } return credentials; }
static void PromptLumosInstall() { EditorApplication.projectWindowChanged -= PromptLumosInstall; EditorApplication.hierarchyWindowChanged -= PromptLumosInstall; credentials = LumosCredentialsManager.GetCredentials(); if (credentials.apiKey.Length >= 32) { return; } // Make window pop up EditorWindow.GetWindow<LumosInstall>(true, "Install Lumos"); }
/// <summary> /// Gets the user's Lumos credentials, creating a new object if necessary. /// </summary> /// <returns>Lumos credentials.</returns> public static LumosCredentials GetCredentials() { if (credentials == null) { credentials = LumosCredentials.Load(); if (credentials == null) { credentials = CreateCredentials(); } } return(credentials); }
/// <summary> /// Creates an authorization header. /// </summary> /// <param name="credentials">Lumos credentials object.</param> /// <param name="postData">The POST body.</param> /// <returns>A string suitable for the HTTP Authorization header.</returns> public static string GenerateAuthorizationHeader(LumosCredentials credentials, byte[] postData) { if (postData == null) { postData = new byte[] {}; } var secret = Encoding.ASCII.GetBytes(credentials.apiKey); var hmac = new HMACSHA1(secret); var hash = hmac.ComputeHash(postData); var auth = Convert.ToBase64String(hash); var header = "Lumos " + credentials.gameID + ":" + auth; return(header); }
static void PromptLumosInstall() { EditorApplication.projectWindowChanged -= PromptLumosInstall; EditorApplication.hierarchyWindowChanged -= PromptLumosInstall; credentials = LumosCredentialsManager.GetCredentials(); if (credentials.apiKey.Length >= 32) { return; } // Make window pop up EditorWindow.GetWindow <LumosInstall>(true, "Install Lumos"); }
/// <summary> /// Creates an authorization header. /// </summary> /// <param name="credentials">Lumos credentials object.</param> /// <param name="postData">The POST body.</param> /// <returns>A string suitable for the HTTP Authorization header.</returns> public static string GenerateAuthorizationHeader (LumosCredentials credentials, byte[] postData) { if (postData == null) { postData = new byte[] {}; } var secret = Encoding.ASCII.GetBytes(credentials.apiKey); var hmac = new HMACSHA1(secret); var hash = hmac.ComputeHash(postData); var auth = Convert.ToBase64String(hash); var header = "Lumos " + credentials.gameID + ":" + auth; return header; }
public static bool HasCredentialsFile() { credentials = LumosCredentials.Load(); return credentials != null; }
public static bool HasCredentialsFile() { credentials = LumosCredentials.Load(); return(credentials != null); }