-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #452 from Unity-Technologies/staging
0.1.1 staging > master
- Loading branch information
Showing
105 changed files
with
6,658 additions
and
5,427 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#if UNITY_2017_2_OR_NEWER | ||
using System; | ||
using System.Collections.Generic; | ||
using UnityEditor.Experimental.EditorVR.Modules; | ||
using UnityEditor.Experimental.EditorVR.Proxies; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.Experimental.EditorVR.UI | ||
{ | ||
sealed class ProxyFeedbackEditor : EditorWindow | ||
{ | ||
readonly Dictionary<Type, SerializedProxyFeedback> m_SerializedFeedback = new Dictionary<Type, SerializedProxyFeedback>(); | ||
Vector2 m_Scroll; | ||
|
||
[MenuItem("Edit/Project Settings/EditorXR/Proxy Feedback")] | ||
static void Init() | ||
{ | ||
GetWindow<ProxyFeedbackEditor>("Proxy Feedback Editor").Show(); | ||
} | ||
|
||
void OnEnable() | ||
{ | ||
Refresh(); | ||
} | ||
|
||
void OnGUI() | ||
{ | ||
if (Event.current.Equals(Event.KeyboardEvent("^w"))) | ||
{ | ||
Close(); | ||
GUIUtility.ExitGUI(); | ||
} | ||
|
||
if (GUILayout.Button("Reload Data")) | ||
Refresh(); | ||
|
||
if (GUILayout.Button("Clear Data")) | ||
{ | ||
ClearData(); | ||
Refresh(); | ||
} | ||
|
||
if (GUILayout.Button("Save Data")) | ||
{ | ||
SaveData(); | ||
Refresh(); | ||
} | ||
|
||
m_Scroll = GUILayout.BeginScrollView(m_Scroll); | ||
var hasFeedback = false; | ||
foreach (var kvp in m_SerializedFeedback) | ||
{ | ||
GUILayout.Label(kvp.Key.Name, EditorStyles.boldLabel); | ||
DrawPreferences(kvp.Value); | ||
hasFeedback = true; | ||
} | ||
|
||
if (!hasFeedback) | ||
GUILayout.Label("No serialized feedback"); | ||
|
||
GUILayout.EndScrollView(); | ||
} | ||
|
||
static void DrawPreferences(SerializedProxyFeedback feedback) | ||
{ | ||
GUILayout.Label("Left Hand"); | ||
DrawNode(feedback.leftNode); | ||
GUILayout.Label("Right Hand"); | ||
DrawNode(feedback.rightNode); | ||
} | ||
|
||
static void DrawNode(SerializedProxyNodeFeedback node) | ||
{ | ||
var keys = node.keys; | ||
var values = node.values; | ||
for (var i = 0; i < keys.Length; i++) | ||
{ | ||
var data = values[i]; | ||
data.presentations = EditorGUILayout.IntField(keys[i].ToString(), data.presentations); | ||
} | ||
} | ||
|
||
void Refresh() | ||
{ | ||
m_SerializedFeedback.Clear(); | ||
var preferences = SerializedPreferencesModule.DeserializePreferences(Core.EditorVR.serializedPreferences); | ||
if (preferences == null) | ||
return; | ||
|
||
foreach (var kvp in preferences.items) | ||
{ | ||
var type = kvp.Key; | ||
if (typeof(TwoHandedProxyBase).IsAssignableFrom(type)) | ||
{ | ||
var item = kvp.Value; | ||
Type payloadType = null; | ||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) | ||
{ | ||
payloadType = assembly.GetType(item.payloadType); | ||
if (payloadType != null) | ||
break; | ||
} | ||
|
||
if (payloadType == null) | ||
continue; | ||
|
||
var payload = (SerializedProxyFeedback)JsonUtility.FromJson(item.payload, payloadType); | ||
m_SerializedFeedback[kvp.Key] = payload; | ||
} | ||
} | ||
} | ||
|
||
static void ClearData() | ||
{ | ||
var preferences = SerializedPreferencesModule.DeserializePreferences(Core.EditorVR.serializedPreferences); | ||
if (preferences == null) | ||
return; | ||
|
||
foreach (var kvp in new Dictionary<Type, SerializedPreferencesModule.SerializedPreferenceItem>(preferences.items)) | ||
{ | ||
var type = kvp.Key; | ||
if (typeof(TwoHandedProxyBase).IsAssignableFrom(type)) | ||
preferences.Remove(type); | ||
} | ||
|
||
Core.EditorVR.serializedPreferences = JsonUtility.ToJson(preferences); | ||
} | ||
|
||
void SaveData() | ||
{ | ||
var preferences = SerializedPreferencesModule.DeserializePreferences(Core.EditorVR.serializedPreferences); | ||
if (preferences == null) | ||
return; | ||
|
||
var items = preferences.items; | ||
foreach (var kvp in m_SerializedFeedback) | ||
{ | ||
items[kvp.Key].payload = JsonUtility.ToJson(kvp.Value); | ||
} | ||
|
||
Core.EditorVR.serializedPreferences = JsonUtility.ToJson(preferences); | ||
} | ||
} | ||
} | ||
#endif |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.