Skip to content

Commit 4f42b2a

Browse files
v 1.1.1
Added ability to use preconfigured display PictureWindow.cs: - Set to default to TopLeft instruction - Added check to see if RealWindow is already positioned, and if so to use it's dimensions PictureWindowCamera.cs: - Added check to ensure WindowController is set PictureWindowUI.cs: - Added Instruction display for "Click the trigger to begin" and associated logic in order to assign WindowController
1 parent 6d1f07a commit 4f42b2a

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

Assets/SmirkingCat/Scripts/PictureWindow.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ private void Awake()
6969
private IEnumerator Start()
7070
{
7171

72+
WindowUI.ShowInstruction(PictureWindowUI.INSTRUCTION.TopLeft);
73+
7274
// Set Cursor to not be visible
7375
Cursor.visible = false;
7476

@@ -112,6 +114,42 @@ private void Update()
112114

113115
if (_targetBox) _targetBox.SetActive(UseTargetBox);
114116

117+
if (!IsConfigured)
118+
{
119+
120+
if (RealWindow.Display.transform.position != Vector3.zero)
121+
{
122+
123+
WindowUI.ShowInstruction(PictureWindowUI.INSTRUCTION.Trigger);
124+
125+
if (WindowController)
126+
{
127+
128+
MeshFilter rend = RealWindow.Display.GetComponent<MeshFilter>();
129+
130+
// Set the corners based on the corners of the configured Quad
131+
RealWindow.BottomLeft = RealWindow.Display.transform.TransformPoint(rend.mesh.vertices[0]);
132+
RealWindow.TopRight = RealWindow.Display.transform.TransformPoint(rend.mesh.vertices[1]);
133+
RealWindow.BottomRight = RealWindow.Display.transform.TransformPoint(rend.mesh.vertices[2]);
134+
RealWindow.TopLeft = RealWindow.Display.transform.TransformPoint(rend.mesh.vertices[3]);
135+
136+
// Duplicate everything over to the VirtualWindow
137+
VirtualWindow.TopLeft = RealWindow.TopLeft;
138+
VirtualWindow.BottomLeft = RealWindow.BottomLeft;
139+
VirtualWindow.BottomRight = RealWindow.BottomRight;
140+
VirtualWindow.TopRight = RealWindow.TopRight;
141+
142+
// Set the config flag
143+
IsConfigured = true;
144+
145+
// Turn the instructions off
146+
WindowUI.ShowInstruction(PictureWindowUI.INSTRUCTION.None);
147+
}
148+
149+
}
150+
151+
}
152+
115153
}
116154

117155

Assets/SmirkingCat/Scripts/PictureWindowCamera.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private void LateUpdate()
4242
{
4343

4444

45-
if (PW && PW.IsConfigured)
45+
if (PW && PW.IsConfigured && PW.WindowController)
4646
{
4747

4848
if (!IsConfigured) ConfigureCamera();

Assets/SmirkingCat/Scripts/PictureWindowUI.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class PictureWindowUI : MonoBehaviour
1818

1919
private GameObject _instruction, _reset, _subtitle;
2020

21-
private RectTransform _instructionArrow;
21+
private RectTransform _instructionArrow, _instructionNote;
2222

2323
private Text _instructionText, _subtitleText;
2424

@@ -36,6 +36,7 @@ public enum INSTRUCTION
3636
TopLeft,
3737
BottomLeft,
3838
BottomRight,
39+
Trigger
3940

4041
}
4142

@@ -46,9 +47,10 @@ private void Awake()
4647
// Get all the instruction stuff and default to the first one
4748
_instruction = transform.Find("Canvas/Instruction").gameObject;
4849
_instructionArrow = _instruction.transform.Find("Arrow").GetComponentInChildren<RectTransform>();
50+
_instructionNote = _instruction.transform.Find("Note").GetComponentInChildren<RectTransform>();
4951
_instructionText = _instruction.transform.Find("Text").GetComponentInChildren<Text>();
5052

51-
ShowInstruction(INSTRUCTION.TopLeft);
53+
ShowInstruction(INSTRUCTION.None);
5254

5355
// Get the reset meter and related components
5456
_reset = transform.Find("Canvas/Reset").gameObject;
@@ -104,6 +106,13 @@ public void ShowInstruction(INSTRUCTION instruction)
104106
ShowInstruction(new Vector2(-110, 110), new Vector2(1, 0), new Vector2(1, 0), Quaternion.Euler(0, 0, 0), "bottom right");
105107
break;
106108

109+
case INSTRUCTION.Trigger:
110+
_instruction.SetActive(true);
111+
_instructionArrow.gameObject.SetActive(false);
112+
_instructionNote.gameObject.SetActive(false);
113+
_instructionText.text = "Click the trigger to begin";
114+
break;
115+
107116
case INSTRUCTION.None:
108117
default:
109118
_instruction.SetActive(false);
@@ -119,6 +128,8 @@ private void ShowInstruction(Vector2 anchor, Vector2 anchorMin, Vector2 anchorMa
119128
{
120129

121130
_instruction.SetActive(true);
131+
_instructionArrow.gameObject.SetActive(true);
132+
_instructionNote.gameObject.SetActive(true);
122133
_instructionArrow.anchoredPosition = anchor;
123134
_instructionArrow.anchorMin = anchorMin;
124135
_instructionArrow.anchorMax = anchorMax;

0 commit comments

Comments
 (0)