Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
ported some standard shader changes and added tmpro shader variant (#141
Browse files Browse the repository at this point in the history
)

* ported some standard shader changes and added tmpro shader variant

* added missing icon

* Added a missing inspector for the bezier
Updated dotted line png meta
Exposed distortion settings as they could be added later.

* Fixed icon and renamed class
  • Loading branch information
StephenHodgson authored Apr 30, 2019
1 parent f02fcc2 commit d338896
Show file tree
Hide file tree
Showing 19 changed files with 1,716 additions and 184 deletions.
146 changes: 89 additions & 57 deletions Inspectors/MixedRealityStandardShaderGUI.cs

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions Inspectors/Text3DShaderGUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using UnityEditor;
using UnityEngine;

namespace XRTK.Inspectors
{
/// <summary>
/// A custom shader inspector for the "Mixed Reality Toolkit/TextShader3D".
/// </summary>
public class Text3DShaderGUI : ShaderGUI
{
protected bool firstTimeApply = true;
protected MaterialProperty cullMode;


public override void OnGUI(MaterialEditor matEditor, MaterialProperty[] props)
{
// Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching from an existing material.
// Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
if (firstTimeApply)
{
firstTimeApply = false;
}

EditorGUIUtility.labelWidth = 0f;

EditorGUI.BeginChangeCheck();
{
base.OnGUI(matEditor, props);
}
}

protected static class Styles
{
public static GUIContent cullMode = new GUIContent("Culling Mode", "Type of culling to apply to polygons - typically this is set to backfacing");
}
}
}
11 changes: 11 additions & 0 deletions Inspectors/Text3DShaderGUI.cs.meta

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
Expand Up @@ -253,23 +253,15 @@ public override void OnInspectorGUI()

if (distortionSettingsFoldout)
{
if (distorters.arraySize > 0)
{
EditorGUI.indentLevel++;
EditorGUILayout.HelpBox("No distorters attached to this line.\nTry adding a distortion component.", MessageType.Info);

if (distorters.arraySize > 0)
{
EditorGUILayout.PropertyField(distortionMode);
EditorGUILayout.PropertyField(distortionStrength);
EditorGUILayout.PropertyField(uniformDistortionStrength);
}
EditorGUI.indentLevel++;

EditorGUI.indentLevel--;
}
else
{
EditorGUILayout.HelpBox("No distorters attached to this line.\nTry adding a distortion component.", MessageType.Info);
}
EditorGUILayout.PropertyField(distortionMode);
EditorGUILayout.PropertyField(distortionStrength);
EditorGUILayout.PropertyField(uniformDistortionStrength);

EditorGUI.indentLevel--;
}

serializedObject.ApplyModifiedProperties();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using UnityEditor;
using UnityEngine;
using XRTK.Utilities.Lines;

namespace XRTK.Inspectors.Utilities.Lines.DataProviders
{
[CustomEditor(typeof(BezierLineDataProvider))]
public class BezierDataProviderInspector : BaseMixedRealityLineDataProviderInspector
{
private const float HANDLE_SIZE_MODIFIER = 0.04f;
private const float PICK_SIZE_MODIFIER = 0.06f;

private SerializedProperty controlPoints;
private SerializedProperty inertia;
private SerializedProperty useLocalTangentPoints;

private int selectedHandleIndex = -1;

protected override void OnEnable()
{
base.OnEnable();

controlPoints = serializedObject.FindProperty("controlPoints");
inertia = serializedObject.FindProperty("inertia");
useLocalTangentPoints = serializedObject.FindProperty("useLocalTangentPoints");
}

public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();

// We always draw line points for bezier.
DrawLinePoints = true;

EditorGUILayout.PropertyField(controlPoints, true);
EditorGUILayout.PropertyField(inertia, true);
EditorGUILayout.PropertyField(useLocalTangentPoints);

serializedObject.ApplyModifiedProperties();
}

protected override void OnSceneGUI()
{
base.OnSceneGUI();

for (int i = 0; i < 4; i++)
{
serializedObject.Update();

bool isTangentHandle = i % 3 != 0;
bool isLastPoint = i == 3;

var controlPointPosition = LineData.GetPoint(i);
var controlPointProperty = controlPoints.FindPropertyRelative("point" + (i + 1));

// Draw our tangent lines
Handles.color = Color.gray;
if (i == 0)
{
Handles.DrawLine(LineData.GetPoint(0), LineData.GetPoint(1));
}
else if (!isTangentHandle)
{
Handles.DrawLine(LineData.GetPoint(i), LineData.GetPoint(i - 1));

if (!isLastPoint)
{
Handles.DrawLine(LineData.GetPoint(i), LineData.GetPoint(i + 1));
}
}

Handles.color = isTangentHandle ? Color.white : Color.green;
float handleSize = HandleUtility.GetHandleSize(controlPointPosition);

if (Handles.Button(controlPointPosition, Quaternion.identity, handleSize * HANDLE_SIZE_MODIFIER, handleSize * PICK_SIZE_MODIFIER, Handles.DotHandleCap))
{
selectedHandleIndex = i;
}

// Draw our handles
if (Tools.current == Tool.Move && selectedHandleIndex == i)
{
EditorGUI.BeginChangeCheck();

var newTargetPosition = Handles.PositionHandle(controlPointPosition, Quaternion.identity);

if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(LineData, "Change Bezier Point Position");
LineData.SetPoint(i, newTargetPosition);
}
}

serializedObject.ApplyModifiedProperties();
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d338896

Please sign in to comment.