Skip to content

Commit

Permalink
#17 modify for leapmotion
Browse files Browse the repository at this point in the history
  • Loading branch information
harihitode authored and ganmacs committed Dec 13, 2015
1 parent ca83a2e commit f74133a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
77 changes: 77 additions & 0 deletions Assets/Scripts/PhoneButtonScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using LMWidgets;

public class PhoneButtonScript : ButtonBase
{
public ButtonDemoGraphics onGraphics;
public ButtonDemoGraphics offGraphics;
public ButtonDemoGraphics midGraphics;
public ButtonDemoGraphics botGraphics;
public InputField inputField;
public string number;

public Color MidGraphicsOnColor = new Color(0.0f, 0.5f, 0.5f, 1.0f);
public Color BotGraphicsOnColor = new Color(0.0f, 1.0f, 1.0f, 1.0f);
public Color MidGraphicsOffColor = new Color(0.0f, 0.5f, 0.5f, 0.1f);
public Color BotGraphicsOffColor = new Color(0.0f, 0.25f, 0.25f, 1.0f);

protected override void buttonReleased()
{
base.FireButtonEnd ();
TurnsOffGraphics ();
}

protected override void buttonPressed()
{
TurnsOnGraphics();
base.FireButtonStart();
if (number == "D") {
inputField.text = inputField.text.Remove(inputField.text.Length - 1);
} else {
inputField.text += number;
}
}

private void TurnsOnGraphics()
{
onGraphics.SetActive(true);
offGraphics.SetActive(false);
midGraphics.SetColor(MidGraphicsOnColor);
botGraphics.SetColor(BotGraphicsOnColor);
}

private void TurnsOffGraphics()
{
onGraphics.SetActive(false);
offGraphics.SetActive(true);
midGraphics.SetColor(MidGraphicsOffColor);
botGraphics.SetColor(BotGraphicsOffColor);
}

private void UpdateGraphics()
{
Vector3 position = transform.localPosition;
position.z = Mathf.Min(position.z, m_localTriggerDistance);
onGraphics.transform.localPosition = position;
offGraphics.transform.localPosition = position;
Vector3 bot_position = position;
bot_position.z = Mathf.Max(bot_position.z, m_localTriggerDistance - m_localCushionThickness);
botGraphics.transform.localPosition = bot_position;
Vector3 mid_position = position;
mid_position.z = (position.z + bot_position.z) / 2.0f;
midGraphics.transform.localPosition = mid_position;
}

protected override void Start()
{
base.Start();
}

protected override void FixedUpdate()
{
base.FixedUpdate();
UpdateGraphics();
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/PhoneButtonScript.cs.meta

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

Binary file added Assets/_Scenes/Widgets.unity
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/_Scenes/Widgets.unity.meta

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

0 comments on commit f74133a

Please sign in to comment.