-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.