Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Phone #17

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
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.

Loading