Skip to content

Commit

Permalink
Down-tuned pinch gesture to account for better tracking, feels better!
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Benson committed Feb 28, 2018
1 parent 2e6c8fc commit 1bec2a3
Show file tree
Hide file tree
Showing 16 changed files with 1,680 additions and 3,088 deletions.
@@ -0,0 +1,68 @@
using UnityEngine;
using System.Collections;
using Leap.Unity.Animation;
using System;

namespace Leap.Unity.LemurUI {

public class LabelTextMeshDriver : LabelDriver<TextMesh> {

public Label label;
public TextMesh textMesh;

public LabelTextMeshDriver() {
textMesh = driven.gameObject.GetComponent<TextMesh>();

Updater.instance.OnUpdate += onUpdate;
}

public override void Bind(Label label) {
this.label = label;
}

private void onUpdate() {
if (label == null) return;
if (textMesh == null) return;

textMesh.transform.localScale = Vector3.one * 0.01f;

// UnwrapDo: Applies the label color style to the text mesh if it has one.
label.textStyle.color.UnwrapDo(
addArg1: textMesh,
doIfValue: (color, textMesh) => { textMesh.color = color; }
);

textMesh.text = label.text;
}

}

public static class NullableExtensions {

/// <summary>
/// TODO: Move to TodoUMWard and add more argument counts
/// </summary>
public static void UnwrapDo<UnwrapType, Arg1Type>(
this UnwrapType? unwrappedArg0,
Arg1Type addArg1,
Action<UnwrapType, Arg1Type> doIfValue)
where UnwrapType : struct {
if (unwrappedArg0.HasValue) {
doIfValue(unwrappedArg0.Value, addArg1);
}
}
public static void UnwrapDo<UnwrapType, Arg1Type,
Arg2Type>(
this UnwrapType? unwrappedArg0,
Arg1Type addArg1,
Arg2Type addArg2,
Action<UnwrapType, Arg1Type, Arg2Type> doIfValue)
where UnwrapType : struct {
if (unwrappedArg0.HasValue) {
doIfValue(unwrappedArg0.Value, addArg1, addArg2);
}
}

}

}
Expand Up @@ -13,19 +13,38 @@ public struct TextStyle {
public bool? richText;
public Color? color;

public TextStyle Copy() {
return new TextStyle() {
font = font,
fontSize = fontSize,
fontStyle = fontStyle,
richText = richText,
color = color
};
}

/// <summary>
/// Returns a new style with the properties of the argument style overlayed onto this
/// style. Any non-null properties of the argument style will overwrite the
/// corresponding property on this style.
/// </summary>
public TextStyle OverlayedWith(TextStyle other) {
return new TextStyle() {
font = other.font.ValueOr(this.font),
fontSize = other.fontSize.ValueOr(this.fontSize),
fontStyle = other.fontStyle.ValueOr(this.fontStyle),
richText = other.richText.ValueOr(this.richText),
color = other.color.ValueOr(this.color)
};
var copy = Copy();
copy.Overlay(other);
return copy;
}

/// <summary>
/// Overwrites the style properties on this style with non-null properties in the
/// argument style.
/// </summary>
/// <param name="other"></param>
public void Overlay(TextStyle other) {
font = other.font.ValueOr(this.font);
fontSize = other.fontSize.ValueOr(this.fontSize);
fontStyle = other.fontStyle.ValueOr(this.fontStyle);
richText = other.richText.ValueOr(this.richText);
color = other.color.ValueOr(this.color);
}
}

Expand Down
31 changes: 0 additions & 31 deletions Assets/AppModules/AssetTools/LemurUI/Labels/LabelTextMeshDriver.cs

This file was deleted.

9 changes: 8 additions & 1 deletion Assets/AppModules/DevTools/DebugTools/DebugPing.cs
Expand Up @@ -380,7 +380,11 @@ public class PingLine : PingObject {
}

private static void drawLineGizmos(RuntimeGizmoDrawer drawer) {
var color = drawer.color;
foreach (var idLinePair in _pingLines) {
if (idLinePair.Value.color != color) {
color = drawer.color = idLinePair.Value.color;
}
idLinePair.Value.Draw(drawer);
}
}
Expand Down Expand Up @@ -440,7 +444,10 @@ public class PingLabel : PingObject {
label.gameObject.transform.position = labeledPosition;
label.gameObject.transform.rotation = Utils.FaceTargetWithoutTwist(
labeledPosition,
facingPosition);
facingPosition,
flip180: true);

label.textStyle.Overlay(Style.Color(this.color));

label.text = this.text;
}
Expand Down

0 comments on commit 1bec2a3

Please sign in to comment.