-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
Initial commit, migrate from Google Code, r11
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Ll]ibrary/ | ||
[Tt]emp/ | ||
[Oo]bj/ | ||
|
||
# Autogenerated VS/MD solution and project files | ||
*.csproj | ||
*.unityproj | ||
*.sln |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright (c) 2012 Rebel Hippo Inc. All rights reserved. | ||
|
||
using System; | ||
using System.Net; | ||
using System.Text; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// Report issues with Lumos. Open from the Help > Lumos > Report a Bug menu. | ||
/// </summary> | ||
public class LumosBugReporter : EditorWindow | ||
{ | ||
static readonly GUIContent emailLabel = new GUIContent("Email", "Your email address (optional)."); | ||
static readonly GUIContent issueLabel = new GUIContent("Issue", "Details about the problem you're running into."); | ||
static readonly GUIContent submitLabel = new GUIContent("Submit", "Send your issue."); | ||
|
||
static readonly GUIContent sentNotification = new GUIContent("Bug Report Sent\nThanks!"); | ||
static readonly GUIContent errorNotification = new GUIContent("An Error Occurred\nBug Report Not Sent"); | ||
|
||
string email = ""; // Optional | ||
string issue = ""; | ||
|
||
bool inProgress; | ||
GUIContent currentNotification; | ||
|
||
static bool debug = false; | ||
|
||
void OnGUI () | ||
{ | ||
EditorGUILayout.BeginHorizontal(); | ||
|
||
EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false)); | ||
GUILayout.Label(emailLabel); | ||
GUILayout.Label(issueLabel); | ||
EditorGUILayout.EndVertical(); | ||
|
||
EditorGUILayout.BeginVertical(); | ||
email = EditorGUILayout.TextField(email); | ||
issue = EditorGUILayout.TextArea(issue, GUILayout.ExpandHeight(true)); | ||
|
||
GUI.enabled = issue != ""; | ||
|
||
if (inProgress) { | ||
// Draw progress bar | ||
// This doesn't accurately reflect the request's progress, but it indicates that something is happening | ||
var rect = GUILayoutUtility.GetRect(submitLabel, GUI.skin.button); | ||
EditorGUI.ProgressBar(rect, 0.4f, "Sending..."); | ||
} else { | ||
if (GUILayout.Button(submitLabel)) { | ||
ReportBug(); | ||
} | ||
} | ||
EditorGUILayout.EndVertical(); | ||
|
||
EditorGUILayout.EndHorizontal(); | ||
EditorGUILayout.Space(); | ||
|
||
if (currentNotification != null) { | ||
ShowNotification(currentNotification); | ||
currentNotification = null; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously sends the bug report to the server. | ||
/// </summary> | ||
void ReportBug () | ||
{ | ||
var message = "email=" + email + "&issue=" + issue; | ||
var bytes = Encoding.UTF8.GetBytes(message); | ||
|
||
var url = "http://" + (debug ? "localhost:8080" : "www.uselumos.com") + "/report-bug"; | ||
var request = WebRequest.Create(url); | ||
request.Method = "POST"; | ||
request.ContentLength = bytes.Length; | ||
request.ContentType = "application/x-www-form-urlencoded"; | ||
|
||
try { | ||
var stream = request.GetRequestStream(); | ||
stream.Write(bytes, 0, bytes.Length); | ||
stream.Close(); | ||
request.BeginGetResponse(new AsyncCallback(ResponseCallback), request); | ||
inProgress = true; | ||
} catch (Exception e) { | ||
if (debug) { Debug.LogError("[Lumos] Bug report not sent. " + e.Message); } | ||
currentNotification = errorNotification; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Called upon completion of the asynchronous request to the server. | ||
/// </summary> | ||
/// <param name="ar">Asynchronous result.</param> | ||
void ResponseCallback (IAsyncResult ar) | ||
{ | ||
var request = (WebRequest)ar.AsyncState; | ||
request.EndGetResponse(ar); | ||
inProgress = false; | ||
currentNotification = sentNotification; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2012 Rebel Hippo Inc. All rights reserved. | ||
|
||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// A custom inspector for the Lumos game object. | ||
/// </summary> | ||
[CustomEditor(typeof(Lumos))] | ||
public class LumosInspector : Editor | ||
{ | ||
GUIContent secretKeyLabel = new GUIContent("Secret Key", "Your application's secret key."); | ||
GUIContent recordInEditorLabel = new GUIContent("Record While In Editor", "Send data to Lumos during development."); | ||
GUIContent recordPresetEventsLabel = new GUIContent("Record Preset Events", "Record pre-configured events."); | ||
GUIContent recordErrorsLabel = new GUIContent("Record Errors", "Report error messages sent to Unity's console."); | ||
GUIContent recordWarningsLabel = new GUIContent("Record Warnings", "Report warning message sent to Unity's console."); | ||
GUIContent recordLogsLabel = new GUIContent("Record Logs", "Report debug log message sent to Unity's console."); | ||
|
||
override public void OnInspectorGUI () | ||
{ | ||
var lumos = target as Lumos; | ||
|
||
EditorGUIUtility.LookLikeInspector(); | ||
EditorGUI.indentLevel = 1; | ||
|
||
lumos.secretKey = EditorGUILayout.TextField(secretKeyLabel, lumos.secretKey); | ||
lumos.runInEditor = EditorGUILayout.Toggle(recordInEditorLabel, lumos.runInEditor); | ||
lumos.recordPresetEvents = EditorGUILayout.Toggle(recordPresetEventsLabel, lumos.recordPresetEvents); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
lumos.recordErrors = EditorGUILayout.Toggle(recordErrorsLabel, lumos.recordErrors); | ||
lumos.recordWarnings = EditorGUILayout.Toggle(recordWarningsLabel, lumos.recordWarnings); | ||
lumos.recordLogs = EditorGUILayout.Toggle(recordLogsLabel, lumos.recordLogs); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2012 Rebel Hippo Inc. All rights reserved. | ||
|
||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// Menus for various functionality. | ||
/// </summary> | ||
public static class LumosMenus | ||
{ | ||
const string documentationUrl = "http://www.uselumos.com/supports/docs"; | ||
|
||
/// <summary> | ||
/// Adds "Add To Scene" menu item to the Window menu. | ||
/// This triggers a wizard which prompts the user for their secret key before instantiating the Lumos prefab. | ||
/// </summary> | ||
[MenuItem("GameObject/Create Other/Lumos...")] | ||
static void AddToScene () | ||
{ | ||
ScriptableWizard.DisplayWizard<LumosWizard>("Add Lumos To Scene", "Add", "Cancel"); | ||
} | ||
|
||
/// <summary> | ||
/// Validates the "Add To Scene" menu item, disabling it if a Lumos instance already exists in the scene. | ||
/// </summary> | ||
/// <returns>Whether or not the menu is enabled.</returns> | ||
[MenuItem("GameObject/Create Other/Lumos...", true)] | ||
static bool ValidateAddToScene () | ||
{ | ||
var go = GameObject.Find("Lumos"); | ||
return go == null; | ||
} | ||
|
||
/// <summary> | ||
/// Adds link to Lumos website to Help menu. | ||
/// </summary> | ||
[MenuItem("Help/Lumos/Documentation")] | ||
static void DisplayWebsite () | ||
{ | ||
Help.BrowseURL(documentationUrl); | ||
} | ||
|
||
/// <summary> | ||
/// Adds menu item to open the Lumos bug reporter. | ||
/// </summary> | ||
[MenuItem("Help/Lumos/Report a Bug")] | ||
static void OpenBugReporter () | ||
{ | ||
// Get existing open window, or make new one if none | ||
var window = EditorWindow.GetWindow<LumosBugReporter>(); | ||
window.title = "Report Bug"; | ||
window.Show(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2012 Rebel Hippo Inc. All rights reserved. | ||
|
||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// A wizard for instantiating the Lumos game object. | ||
/// </summary> | ||
public class LumosWizard : ScriptableWizard | ||
{ | ||
const string prefabPath = "Assets/Standard Assets/Lumos/Lumos.prefab"; | ||
public string secretKey = ""; | ||
|
||
/// <summary> | ||
/// Called when the "Create" button is pressed. | ||
/// </summary> | ||
void OnWizardCreate () | ||
{ | ||
Undo.RegisterSceneUndo("Add Lumos To Scene"); | ||
|
||
// Instantiate the Lumos object | ||
var prefab = Resources.LoadAssetAtPath(prefabPath, typeof(GameObject)); | ||
var go = PrefabUtility.InstantiatePrefab(prefab) as GameObject; | ||
go.GetComponent<Lumos>().secretKey = secretKey; | ||
} | ||
|
||
/// <summary> | ||
/// Called when the "Cancel" button is pressed. | ||
/// </summary> | ||
void OnWizardOtherButton () | ||
{ | ||
Close(); | ||
} | ||
|
||
/// <summary> | ||
/// UI elements. | ||
/// </summary> | ||
void OnWizardUpdate () | ||
{ | ||
helpString = "Fill in your application's secret key below."; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.