8000 Fixed rendering problems for 2019 by StephenHodgson · Pull Request #575 · XRTK/com.xrtk.core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Aug 11, 2024. It is now read-only.

Fixed rendering problems for 2019 #575

Merged
merged 2 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

49 changes: 36 additions & 13 deletions XRTK-Core/Packages/com.xrtk.core/Editor/ControllerPopupWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,39 @@ public class ControllerPopupWindow : EditorWindow
private SerializedProperty currentInteractionProfiles;

private Vector2 mouseDragOffset;
private GUIStyle flippedLabelStyle;

private static GUIStyle labelStyle;
private static GUIStyle LabelStyle => labelStyle ?? (labelStyle = new GUIStyle(EditorStyles.label)
{
alignment = TextAnchor.MiddleLeft,
normal = new GUIStyleState
{
textColor = EditorGUIUtility.isProSkin
? Color.white
: Color.black
},
stretchHeight = true,
stretchWidth = true,
});

private static GUIStyle flippedLabelStyle;
private static GUIStyle FlippedLabelStyle => flippedLabelStyle ?? (flippedLabelStyle = new GUIStyle(EditorStyles.label)
{
alignment = TextAnchor.MiddleRight,
normal = new GUIStyleState
{
textColor = EditorGUIUtility.isProSkin
? Color.white
: Color.black
},
stretchHeight = true,
stretchWidth = true,
});

private static GUIStyle backgroundStyle;

private static GUIStyle BackgroundStyle => backgroundStyle ?? (backgroundStyle = new GUIStyle(EditorStyles.toolbar));

private Texture2D currentControllerTexture;
private ControllerInputActionOption currentControllerOption;

Expand Down Expand Up @@ -97,9 +129,9 @@ public static void Show(MixedRealityControllerMappingProfile profile, Serialized
return;
}

window.currentControllerName = profile.ControllerType.Type.Name;
window = (ControllerPopupWindow)CreateInstance(typeof(ControllerPopupWindow));

window.currentControllerName = profile.ControllerType.Type.Name;
window.titleContent = new GUIContent($"{window.currentControllerName} {handednessTitleText}Input Action Assignment");
window.controllerDataProviderProfile = profile;
window.currentInteractionProfiles = interactionMappingProfiles;
Expand Down Expand Up @@ -177,15 +209,6 @@ private void Update()

private void OnGUI()
{
if (flippedLabelStyle == null)
{
flippedLabelStyle = new GUIStyle("Label")
{
alignment = TextAnchor.UpperRight,
stretchWidth = true
};
}

if (!IsCustomController && currentControllerTexture != null)
{
GUILayout.BeginHorizontal();
Expand Down Expand Up @@ -361,7 +384,7 @@ private void RenderInteractionList(SerializedProperty interactionProfilesList, b
rectPosition.y += (i + 1) * (EditorGUIUtility.singleLineHeight + 2);
}

GUI.Box(new Rect(rectPosition, rectSize), GUIContent.none, EditorGUIUtility.isProSkin ? "ObjectPickerBackground" : "ObjectPickerResultsEven");
GUI.Box(new Rect(rectPosition, rectSize), GUIContent.none, BackgroundStyle);

var offset = flipped ? InputActionLabelPosition : Vector2.zero;
var popupRect = new Rect(rectPosition + offset, new Vector2(InputActionDropdownPosition.x, EditorGUIUtility.singleLineHeight));
Expand All @@ -370,7 +393,7 @@ private void RenderInteractionList(SerializedProperty interactionProfilesList, b

offset = flipped ? Vector2.zero : InputActionDropdownPosition;
var labelRect = new Rect(rectPosition + offset, new Vector2(InputActionLabelPosition.x, EditorGUIUtility.singleLineHeight));
EditorGUI.LabelField(labelRect, interactionDescription.stringValue, flipped ? flippedLabelStyle : EditorStyles.label);
EditorGUI.LabelField(labelRect, interactionDescription.stringValue, flipped ? FlippedLabelStyle : LabelStyle);

if (editInputActionPositions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
using XRTK.Definitions;
using XRTK.Editor.Extensions;
using XRTK.Editor.Profiles;
using XRTK.Editor.Utilities;
using XRTK.Services;

namespace XRTK.Editor
{
[CustomEditor(typeof(MixedRealityToolkit))]
public class MixedRealityToolkitInspector : BaseMixedRealityToolkitInspector
public class MixedRealityToolkitInspector : UnityEditor.Editor
{
private SerializedProperty activeProfile;
private int currentPickerWindow = -1;
Expand All @@ -38,7 +39,7 @@ private void OnEnable()

public override void OnInspectorGUI()
{
RenderMixedRealityToolkitLogo();
MixedRealityInspectorUtility.RenderMixedRealityToolkitLogo();

serializedObject.Update();
EditorGUI.BeginChangeCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void RenderHeader(string infoBoxText = "", Texture2D image = null)
}
else
{
MixedRealityInspectorUtility.RenderCustomHeader(image);
MixedRealityInspectorUtility.RenderInspectorHeader(image);
}

if (ThisProfile.ParentProfile != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,19 @@ public class BaseMixedRealityControllerDataProviderProfileInspector : BaseMixedR
private ReorderableList mappingProfileList;
private int currentlySelectedElement;
private int selectedMappingsViewModeTab = 0;

private GUIStyle controllerButtonStyle;

private GUIStyle ControllerButtonStyle => controllerButtonStyle ?? (controllerButtonStyle = new GUIStyle("button")
{
imagePosition = ImagePosition.ImageAbove,
fontStyle = FontStyle.Bold,
stretchHeight = true,
stretchWidth = true,
wordWrap = true,
fontSize = 10,
});

protected override void OnEnable()
{
base.OnEnable();
Expand Down Expand Up @@ -258,19 +269,6 @@ internal void RenderControllerMappingButton(MixedRealityControllerMappingProfile
{
var controllerType = controllerMappingProfile.ControllerType.Type;

if (controllerButtonStyle == null)
{
controllerButtonStyle = new GUIStyle("LargeButton")
{
imagePosition = ImagePosition.ImageAbove,
fontStyle = FontStyle.Bold,
stretchHeight = true,
stretchWidth = true,
wordWrap = true,
fontSize = 10,
};
}

var handedness = controllerMappingProfile.Handedness;

if (handedness != Handedness.Right)
Expand All @@ -286,7 +284,7 @@ internal void RenderControllerMappingButton(MixedRealityControllerMappingProfile
}

var buttonContent = new GUIContent($"Edit {typeName} Action Mapping", ControllerMappingLibrary.GetControllerTextureScaled(controllerMappingProfile));
if (GUILayout.Button(buttonContent, controllerButtonStyle, GUILayout.Height(128f), GUILayout.MinWidth(32f), GUILayout.ExpandWidth(true)))
if (GUILayout.Button(buttonContent, ControllerButtonStyle, GUILayout.Height(128f), GUILayout.MinWidth(32f), GUILayout.ExpandWidth(true)))
{
EditorApplication.delayCall += () => ControllerPopupWindow.Show(controllerMappingProfile, new SerializedObject(controllerMappingProfile).FindProperty("interactionMappingProfiles"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
var propertyLabel = EditorGUI.BeginProperty(position, label, property);
var profileType = ProfileTypeOverride ?? fieldInfo.FieldType;
var hasSelection = property.objectReferenceValue != null;
var buttonWidth = hasSelection ? 42f : 20f;
var buttonWidth = hasSelection ? 48f : 20f;
var objectRect = position;

if (DrawCloneButtons)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,25 @@ public static Texture2D LightThemeLogo

private static Texture2D lightThemeLogo = null;

private static GUIStyle centeredGuiStyle;

private static GUIStyle CenteredGuiStyle => centeredGuiStyle ?? (centeredGuiStyle = new GUIStyle { alignment = TextAnchor.MiddleCenter });

/// <summary>
/// Render the Mixed Reality Toolkit Logo.
/// </summary>
public static void RenderMixedRealityToolkitLogo()
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label(EditorGUIUtility.isProSkin ? LightThemeLogo : DarkThemeLogo, GUILayout.MaxHeight(128f));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Space(12f);
RenderInspectorHeader(EditorGUIUtility.isProSkin ? LightThemeLogo : DarkThemeLogo);
}

/// <summary>
/// Render a custom header for the profile inspector.
/// Render a header for the profile inspector.
/// </summary>
/// <param name="image"></param>
public static void RenderCustomHeader(Texture2D image)
public static void RenderInspectorHeader(Texture2D image)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label(image, GUILayout.MaxHeight(128f));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.Label(image, CenteredGuiStyle, GUILayout.MaxHeight(128f));
GUILayout.Space(12f);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ protected BaseController() { }
/// <param name="controllerMappingProfile"></param>
protected BaseController(IMixedRealityControllerDataProvider controllerDataProvider, TrackingState trackingState, Handedness controllerHandedness, MixedRealityControllerMappingProfile controllerMappingProfile)
{
if (controllerMappingProfile == null)
{
throw new Exception($"{nameof(controllerMappingProfile)} cannot be null");
}

ControllerDataProvider = controllerDataProvider;
TrackingState = trackingState;
ControllerHandedness = controllerHandedness;
Expand Down
0