Apply most requested changes
This commit is contained in:
@@ -637,6 +637,11 @@ Transform:
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &245326894 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8299246693487308514, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
m_PrefabInstance: {fileID: 667202412}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &281479528
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -793,6 +798,80 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &496523652
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 496523653}
|
||||
- component: {fileID: 496523655}
|
||||
- component: {fileID: 496523654}
|
||||
m_Layer: 5
|
||||
m_Name: Webcam-bg
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &496523653
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 496523652}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 711818225}
|
||||
m_Father: {fileID: 906197777}
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -612, y: 187}
|
||||
m_SizeDelta: {x: 464.2643, y: 449.3374}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &496523654
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 496523652}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Texture: {fileID: 8400000, guid: 60bb0835fc4bbb043b9b3d8ef48f96a8, type: 2}
|
||||
m_UVRect:
|
||||
serializedVersion: 2
|
||||
x: 1
|
||||
y: 0
|
||||
width: -1
|
||||
height: 1
|
||||
--- !u!222 &496523655
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 496523652}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &519420028
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1509,14 +1588,14 @@ PrefabInstance:
|
||||
- target: {fileID: 8299246693487308512, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
objectReference: {fileID: 667202414}
|
||||
- target: {fileID: 8299246693487308512, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
|
||||
value: GotoThemeSelection
|
||||
value: Back
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8299246693487308512, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName
|
||||
value: SpellingBeeWebcam, Assembly-CSharp
|
||||
value: BackButton, CommonScripts
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8299246693487308512, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_StringArgument
|
||||
@@ -1610,13 +1689,26 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 4518652150503380115, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
--- !u!224 &667202413 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 8299246693487308515, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3}
|
||||
m_PrefabInstance: {fileID: 667202412}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &667202414
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 245326894}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c3dd279b546423e4a8a1b28819a6c4a1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &691634122
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1701,6 +1793,51 @@ SpriteRenderer:
|
||||
m_WasSpriteAssigned: 0
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!1 &711818224
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 711818225}
|
||||
- component: {fileID: 711818226}
|
||||
m_Layer: 0
|
||||
m_Name: Webcam-controller
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &711818225
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 711818224}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -271, y: -622, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 496523653}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &711818226
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 711818224}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 98f2ddd1188ed310e8733106251729b6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
display: {fileID: 496523654}
|
||||
--- !u!1 &757133117
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2266,6 +2403,7 @@ RectTransform:
|
||||
- {fileID: 114026903}
|
||||
- {fileID: 128049075}
|
||||
- {fileID: 1627575592}
|
||||
- {fileID: 496523653}
|
||||
m_Father: {fileID: 1768150806}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
||||
@@ -145,17 +145,27 @@ public class JustSignController : MonoBehaviour
|
||||
currentTheme = FindThemeByName(PlayerPrefs.GetString("themeName"));
|
||||
words = currentTheme.words;
|
||||
lastSpawn = Time.time;
|
||||
Debug.Log("BEFORE");
|
||||
SpawnNewSymbol();
|
||||
Debug.Log("AFTER");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update is called once per frame
|
||||
/// </summary>
|
||||
void Update()
|
||||
{
|
||||
{
|
||||
int matchedSymbolIndex = -1;
|
||||
for (int i = 0; i < activeWords.Count; i++) {
|
||||
if (activeWords[i] == answerField.text.ToLower()) {
|
||||
matchedSymbolIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the oldest symbol if the current input matches it
|
||||
if (answerField.text.ToLower() == activeWords[0]) {
|
||||
int difference = Math.Abs((int) (activeSymbols[0].transform.position.x - hitZone.transform.position.x));
|
||||
if (matchedSymbolIndex >= 0) {
|
||||
int difference = Math.Abs((int) (activeSymbols[matchedSymbolIndex].transform.position.x - hitZone.transform.position.x));
|
||||
Debug.Log("HERE");
|
||||
if (difference < perfectBoundary) {
|
||||
feedBack.text = "Perfect!";
|
||||
score += perfectScore;
|
||||
@@ -170,14 +180,16 @@ public class JustSignController : MonoBehaviour
|
||||
score += terribleScore;
|
||||
}
|
||||
|
||||
DestroyRightmostSymbol();
|
||||
DestroySymbolAt(matchedSymbolIndex);
|
||||
answerField.text = "";
|
||||
}
|
||||
|
||||
// Destroy the oldest symbol if it leaves the screen
|
||||
if (activeSymbols[0].GetComponent<RectTransform>().localPosition.x > -trackX) {
|
||||
DestroyRightmostSymbol();
|
||||
score += offscreenScore;
|
||||
if (activeSymbols.Count > 0) {
|
||||
if (activeSymbols[0].GetComponent<RectTransform>().localPosition.x > -trackX) {
|
||||
DestroySymbolAt(0);
|
||||
score += offscreenScore;
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn new symbol every spawn period
|
||||
@@ -197,12 +209,13 @@ public class JustSignController : MonoBehaviour
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Destroy the oldest symbol on the track
|
||||
/// Destroy the symbol at the given index
|
||||
/// </summary>
|
||||
void DestroyRightmostSymbol() {
|
||||
activeWords.RemoveAt(0);
|
||||
GameObject symbol = activeSymbols[0];
|
||||
activeSymbols.RemoveAt(0);
|
||||
/// <param name="index">The index of the symbol to destroy</param>
|
||||
void DestroySymbolAt(int index) {
|
||||
activeWords.RemoveAt(index);
|
||||
GameObject symbol = activeSymbols[index];
|
||||
activeSymbols.RemoveAt(index);
|
||||
Destroy(symbol);
|
||||
}
|
||||
|
||||
@@ -233,21 +246,106 @@ public class JustSignController : MonoBehaviour
|
||||
/// Create a new symbol at the start of the track
|
||||
/// </summary>
|
||||
void SpawnNewSymbol() {
|
||||
string nextSymbol = words[UnityEngine.Random.Range(0, words.Length)];
|
||||
List<int> unusedWordIndices = new List<int>();
|
||||
|
||||
for (int i = 0; i < words.Length; i++) {
|
||||
if (!activeWords.Contains(words[i])) {
|
||||
unusedWordIndices.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
string nextSymbol = words[unusedWordIndices[UnityEngine.Random.Range(0, unusedWordIndices.Count)]];
|
||||
|
||||
GameObject newSymbolObject = new GameObject("Symbol");
|
||||
Image newImage = newSymbolObject.AddComponent<Image>();
|
||||
RectTransform rectTransform = newSymbolObject.GetComponent<RectTransform>();
|
||||
|
||||
RectTransform rectTransform = newSymbolObject.AddComponent<RectTransform>();
|
||||
|
||||
// Add the Image component as a child of the RectTransform
|
||||
Image image = new GameObject("Image").AddComponent<Image>();
|
||||
image.transform.SetParent(rectTransform);
|
||||
|
||||
// Add the Text component as a child of the RectTransform
|
||||
Text text = new GameObject("Text").AddComponent<Text>();
|
||||
text.transform.SetParent(rectTransform);
|
||||
|
||||
// Set the font size of the text component
|
||||
text.fontSize = 100;
|
||||
text.text = "AAAAAAA";
|
||||
text.color = Color.white;
|
||||
|
||||
rectTransform.SetParent(canvas.transform, false); // Set the parent to the Canvas
|
||||
rectTransform.localPosition = new Vector3(trackX, trackY, 0);
|
||||
rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize);
|
||||
rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize + 200f);
|
||||
|
||||
Sprite sprite = Resources.Load<Sprite>("Common/Images/" + nextSymbol);
|
||||
image.sprite = sprite;
|
||||
image.rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize);
|
||||
|
||||
// Set the new sprite as the Image component's source image
|
||||
newImage.sprite = sprite;
|
||||
// Set the position and size of the RectTransform of the text component to match the RectTransform of the image component
|
||||
text.rectTransform.localPosition = new Vector3(0, -50, 0);
|
||||
text.rectTransform.sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
|
||||
activeWords.Add(nextSymbol);
|
||||
activeSymbols.Add(newSymbolObject);
|
||||
}
|
||||
|
||||
/*
|
||||
GameObject newSymbolObject = new GameObject("Symbol");
|
||||
Image image = newSymbolObject.AddComponent<Image>();
|
||||
Sprite sprite = Resources.Load<Sprite>("Common/Images/" + nextSymbol);
|
||||
image.sprite = sprite;
|
||||
//Text text = newSymbolObject.AddComponent<Text>();
|
||||
//text.text = "METTN";
|
||||
RectTransform rectTransform = newSymbolObject.GetComponent<RectTransform>();
|
||||
rectTransform.SetParent(canvas.transform, false); // Set the parent to the Canvas
|
||||
rectTransform.localPosition = new Vector3(trackX, trackY, 0);
|
||||
rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
GameObject newSymbolObject = new GameObject("Symbol");
|
||||
Image newImage = newSymbolObject.AddComponent<Image>();
|
||||
Text text = newSymbolObject.AddComponent<Text>();
|
||||
RectTransform rectTransform = newSymbolObject.GetComponent<RectTransform>();
|
||||
rectTransform.SetParent(canvas.transform, false); // Set the parent to the Canvas
|
||||
rectTransform.localPosition = new Vector3(trackX, trackY, 0);
|
||||
rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize);
|
||||
*/
|
||||
|
||||
/*
|
||||
GameObject newSymbolObject = new GameObject("Symbol");
|
||||
|
||||
RectTransform rectTransform = newSymbolObject.AddComponent<RectTransform>();
|
||||
|
||||
// Add the Image component as a child of the RectTransform
|
||||
Image image = new GameObject("Image").AddComponent<Image>();
|
||||
image.transform.SetParent(rectTransform);
|
||||
|
||||
// Add the Text component as a child of the RectTransform
|
||||
Text text = new GameObject("Text").AddComponent<Text>();
|
||||
text.transform.SetParent(rectTransform);
|
||||
|
||||
// Set the font size of the text component
|
||||
text.fontSize = 30;
|
||||
text.text = "AAAAAAA";
|
||||
text.color = Color.black;
|
||||
|
||||
Sprite sprite = Resources.Load<Sprite>("Common/Images/" + nextSymbol);
|
||||
|
||||
|
||||
|
||||
rectTransform.SetParent(canvas.transform, false); // Set the parent to the Canvas
|
||||
rectTransform.localPosition = new Vector3(trackX, trackY, 0);
|
||||
rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize + 200f);
|
||||
|
||||
Sprite sprite = Resources.Load<Sprite>("Common/Images/" + nextSymbol);
|
||||
image.sprite = sprite;
|
||||
image.rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize);
|
||||
|
||||
// Set the position and size of the RectTransform of the text component to match the RectTransform of the image component
|
||||
text.rectTransform.localPosition = new Vector3(0, -50, 0);
|
||||
text.rectTransform.sizeDelta = rectTransform.sizeDelta;
|
||||
*/
|
||||
}
|
||||
|
||||
72
Assets/JustSign/Scripts/JustSignWebcam.cs
Normal file
72
Assets/JustSign/Scripts/JustSignWebcam.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Class to manage all webcam stuff inside the SpellingBee minigame
|
||||
/// </summary>
|
||||
public class JustSignWebcam : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Index of the current camera
|
||||
/// </summary>
|
||||
int camdex = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Texture to paste on the display
|
||||
/// </summary>
|
||||
WebCamTexture tex;
|
||||
|
||||
/// <summary>
|
||||
/// Display for the video feed
|
||||
/// </summary>
|
||||
public RawImage display;
|
||||
|
||||
/// <summary>
|
||||
/// Setup the webcam correctly
|
||||
/// </summary>
|
||||
void Awake()
|
||||
{
|
||||
WebCamDevice device = WebCamTexture.devices[camdex];
|
||||
tex = new WebCamTexture(device.name);
|
||||
display.texture = tex;
|
||||
|
||||
tex.Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swap webcam by cycling through the `WebCamTexture.devices` list
|
||||
/// </summary>
|
||||
public void SwapCam()
|
||||
{
|
||||
if (WebCamTexture.devices.Length > 0)
|
||||
{
|
||||
// Stop the old camera
|
||||
display.texture = null;
|
||||
tex.Stop();
|
||||
tex = null;
|
||||
|
||||
// Find the new camera
|
||||
camdex += 1;
|
||||
camdex %= WebCamTexture.devices.Length;
|
||||
|
||||
// Start the new camera
|
||||
WebCamDevice device = WebCamTexture.devices[camdex];
|
||||
tex = new WebCamTexture(device.name);
|
||||
display.texture = tex;
|
||||
|
||||
tex.Play();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scene changing is implemented here to avoid problems with webcam
|
||||
/// </summary>
|
||||
public void GotoThemeSelection()
|
||||
{
|
||||
display.texture = null;
|
||||
tex.Stop();
|
||||
tex = null;
|
||||
|
||||
SystemController.GetInstance().BackToPreviousScene();
|
||||
}
|
||||
}
|
||||
11
Assets/JustSign/Scripts/JustSignWebcam.cs.meta
Normal file
11
Assets/JustSign/Scripts/JustSignWebcam.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9291edb7593521fbb7e0a486724fd3c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user