From 2a7dd16f5f0454075a91c47903f3a1d02fb5239c Mon Sep 17 00:00:00 2001 From: Helena Van Breugel Date: Wed, 5 Apr 2023 13:40:54 +0000 Subject: [PATCH] Feedback SpellingBee --- Assets/Common/Interfaces/Learnable.cs | 2 +- .../FingerspellingTheme.asset | 28 ++- Assets/Courses/Scripts/CoursesController.cs | 8 +- .../SpellingBee/Scenes/SpellingBeeGame.unity | 196 ++++++++++++++++-- .../Scripts/SpellingBeeController.cs | 107 ++++++---- 5 files changed, 271 insertions(+), 70 deletions(-) diff --git a/Assets/Common/Interfaces/Learnable.cs b/Assets/Common/Interfaces/Learnable.cs index 39edaa1..92d967e 100644 --- a/Assets/Common/Interfaces/Learnable.cs +++ b/Assets/Common/Interfaces/Learnable.cs @@ -26,7 +26,7 @@ public class Learnable /// /// Addaptive threshold /// - public float thresholdPrecentage = 0.90f; + public float thresholdPercentage = 0.90f; /// /// Example video clip diff --git a/Assets/Common/ScriptableObjects/FingerspellingTheme.asset b/Assets/Common/ScriptableObjects/FingerspellingTheme.asset index f9c1b02..5dbfa93 100644 --- a/Assets/Common/ScriptableObjects/FingerspellingTheme.asset +++ b/Assets/Common/ScriptableObjects/FingerspellingTheme.asset @@ -14,110 +14,136 @@ MonoBehaviour: m_EditorClassIdentifier: title: Handalfabet description: Van A tot Z - index: 0 + themeIndex: 0 modelIndex: 1 learnables: - name: A image: {fileID: 21300000, guid: 4eb4ef55f866f114dafb722f4bd05c76, type: 3} handGuide: {fileID: 21300000, guid: ed5c09a22f5dcb3498f246f9490aa533, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 94a82fe62ff36fc46b79eaca5d78c324, type: 3} - name: B image: {fileID: 21300000, guid: 4dda47b7ae59ce0499ff8e89a310b351, type: 3} handGuide: {fileID: 21300000, guid: 8e050dadd89377d4fb62a4ad8f9e8535, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 318bd1a8b7889b94eb4b679a8e422c82, type: 3} - name: C image: {fileID: 21300000, guid: bb08a500be7994743bdf7f1e38e6538e, type: 3} handGuide: {fileID: 21300000, guid: 330c40bb91dc4b545829054df966ea97, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 788822d230357a141ac24d2fb9c75b96, type: 3} - name: D image: {fileID: 21300000, guid: 3decd69ae4947b240bd680f39b6c5779, type: 3} handGuide: {fileID: 21300000, guid: bd9ec5405bb0fea449e9da0f88c524b3, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 2b276c0661e3c1f46b485c382c3d2eb2, type: 3} - name: E image: {fileID: 21300000, guid: ab8d9fdabea483c409535c3bb26305d8, type: 3} handGuide: {fileID: 21300000, guid: de823bdd2e36be047a6c7937e5bf5cda, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 23b63c8aaace85149adba9082f75bba5, type: 3} - name: F image: {fileID: 21300000, guid: d58ae54ae96a8d741854c485d4c03d52, type: 3} handGuide: {fileID: 21300000, guid: 044b86526fb6697488bbacdc1d76fa03, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: e8272b19b1f494c44a88be82259d8478, type: 3} - name: G image: {fileID: 21300000, guid: d4507d82135bd9a4ea1fa5cc0afe19ba, type: 3} handGuide: {fileID: 21300000, guid: 8e61bbc6d63e9d14f88136e81a0b9d84, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 9793a0da1cef6094fa45dbf42f2f593a, type: 3} - name: H image: {fileID: 21300000, guid: 2720176db57a2384a8b44e023f1548cc, type: 3} handGuide: {fileID: 21300000, guid: ed4e4023600c05347874842b68f62231, type: 3} + thresholdPercentage: 0.8 clip: {fileID: 32900000, guid: 27d1b6711ce142a408ac26b1fcfaf68e, type: 3} - name: I image: {fileID: 21300000, guid: d827fa45fec334e42bdaf76859e73db6, type: 3} handGuide: {fileID: 21300000, guid: d5bbee7ab92ab2149bffdcd93b93a2d3, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: f1022e53c692f5e488bc2bf68ef42c05, type: 3} - name: J image: {fileID: 21300000, guid: 8293bed5458bb2e4380d47a9d78e1ca8, type: 3} handGuide: {fileID: 21300000, guid: 32df0c392f6fbfe4faa3bd6f0f009b7a, type: 3} + thresholdPercentage: 0.95 clip: {fileID: 32900000, guid: ed10642881e9a304ba7a6bfb0a40c871, type: 3} - name: K image: {fileID: 21300000, guid: 2353b41a97a55014a9168e5f19352162, type: 3} handGuide: {fileID: 21300000, guid: 54e8aaec5729e0b438b755ce1c5b8c9f, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: aa5026b1ef45e3742a08c8112e8a6f91, type: 3} - name: L image: {fileID: 21300000, guid: c9ebdbf10e096ed4c9bf08becc1067c3, type: 3} handGuide: {fileID: 21300000, guid: c042d24972c09f849854641b82d164bf, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 4614fd87478f09a4fb0dae142dcb283f, type: 3} - name: M image: {fileID: 21300000, guid: 1d8d7e858fe9d7d4a83ae2c47aa186a9, type: 3} handGuide: {fileID: 21300000, guid: 6014df6c8e5794c4c91b3d7c636b073f, type: 3} + thresholdPercentage: 0.75 clip: {fileID: 32900000, guid: 480ffa4003b79ed41bcd22c25c2b4b0a, type: 3} - name: N image: {fileID: 21300000, guid: 746cc027bdb95d640b2b7c3b717f209c, type: 3} handGuide: {fileID: 21300000, guid: 4a88b6a6c8a4bf5479b9c033313c20dc, type: 3} + thresholdPercentage: 0.7 clip: {fileID: 32900000, guid: 6d40896901cbaad4a9c229e27eee4a0b, type: 3} - name: O image: {fileID: 21300000, guid: cf58cec61def4644d966172584346ea7, type: 3} handGuide: {fileID: 21300000, guid: 13dd6d407842cbc41a74312f86a7451a, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: e100ef044ef83504e859e526ed84cead, type: 3} - name: P image: {fileID: 21300000, guid: 070eca79d6b8ece479abe291f5ecf1f1, type: 3} handGuide: {fileID: 21300000, guid: de3b948a0c6e04547afffebadd53c44e, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 85c4e40c247c2db46bc3eb5b7306d14c, type: 3} - name: Q image: {fileID: 21300000, guid: 26f522f2e30c5b640b3e21aedc311346, type: 3} handGuide: {fileID: 21300000, guid: 189b131f13ce67844933e28c6d031cad, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 34465d640f4c47948b3a3007226eafe3, type: 3} - name: R image: {fileID: 21300000, guid: 5a21107f2fda09e449f052f986c25aee, type: 3} handGuide: {fileID: 21300000, guid: a05e3762c949b83428dc2baf99ab1b34, type: 3} + thresholdPercentage: 0.75 clip: {fileID: 32900000, guid: 29ab11460587e4e458fc5e367245db90, type: 3} - name: S image: {fileID: 21300000, guid: d934313344ebc264cb9a7ab061c5c4aa, type: 3} handGuide: {fileID: 21300000, guid: 5c157ea40838eb74f8226c89a7244613, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 6d7adadd8bbcd284ba047e18fe0b0350, type: 3} - name: T image: {fileID: 21300000, guid: 1c0841dbd38336841acbe8b5d2b70ff4, type: 3} handGuide: {fileID: 21300000, guid: ecd6f60f1bc981b4fb5082ac07e69b6f, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: bb6526ca38b2fda4b8d976d106789f8d, type: 3} - name: U image: {fileID: 21300000, guid: e94c3a7781305514da0676f64c81d231, type: 3} handGuide: {fileID: 21300000, guid: c81ae3b4548e432498e92c09b4f6d0c9, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: b65d525135c41e04fbe646dcf4dc0714, type: 3} - name: V image: {fileID: 21300000, guid: 73ff28d33f02abb4386f970bb3417767, type: 3} handGuide: {fileID: 21300000, guid: 5ab8fc41b65050e4a884ef7ac126318b, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 4ae264889e31d344a80b41449e7d5755, type: 3} - name: W image: {fileID: 21300000, guid: ca7dcaa8441f3314394af32f35d9c5a9, type: 3} handGuide: {fileID: 21300000, guid: f345e4c4670a26e43bb67fdd98d17aa5, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: c4cca5e21c896994088b3f8e55cb619e, type: 3} - name: X image: {fileID: 21300000, guid: 034ab0453d401c243901dc5c74eccda5, type: 3} handGuide: {fileID: 21300000, guid: 2c38602225a250a45be1017aab650a3d, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: ed96233595fdef448bcb5ea59df9915a, type: 3} - name: Y image: {fileID: 21300000, guid: 9e46e7579c4695f429c05fe204fe2442, type: 3} handGuide: {fileID: 21300000, guid: 6f880b9858734b34e8d014189cf0535e, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: f126a23d57436ad4ba1b2130f08bce1e, type: 3} - name: Z image: {fileID: 21300000, guid: e3ddc281a25573d479ee69e8f0196b53, type: 3} handGuide: {fileID: 21300000, guid: de44788bbe2193043a246d12d2df52e5, type: 3} + thresholdPercentage: 0.9 clip: {fileID: 32900000, guid: 39bdb6ec75c70b54f987683f0140e508, type: 3} diff --git a/Assets/Courses/Scripts/CoursesController.cs b/Assets/Courses/Scripts/CoursesController.cs index ca39fe1..06b2988 100644 --- a/Assets/Courses/Scripts/CoursesController.cs +++ b/Assets/Courses/Scripts/CoursesController.cs @@ -340,17 +340,17 @@ public class CoursesController : AbstractFeedback if (feedbackText != null && feedbackProgressImage != null) { Color col; - if (accCurrentSign > sign.thresholdPrecentage) + if (accCurrentSign > sign.thresholdPercentage) { feedbackText.text = "Goed"; col = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f); } - else if (accCurrentSign > 0.9 * sign.thresholdPrecentage) + else if (accCurrentSign > 0.9 * sign.thresholdPercentage) { feedbackText.text = "Bijna"; col = new Color(0xf2 / 255.0f, 0x7f / 255.0f, 0x0c / 255.0f); } - else if (accPredictSign > predSign.thresholdPrecentage) + else if (accPredictSign > predSign.thresholdPercentage) { feedbackText.text = $"Verkeerde gebaar: '{predictedSign}'"; col = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f); @@ -378,7 +378,7 @@ public class CoursesController : AbstractFeedback }); } - if (accPredictSign > sign.thresholdPrecentage) + if (accPredictSign > sign.thresholdPercentage) { // Correct sign if (predictedSign == currentSign) diff --git a/Assets/SpellingBee/Scenes/SpellingBeeGame.unity b/Assets/SpellingBee/Scenes/SpellingBeeGame.unity index f5d1751..927f1b7 100644 --- a/Assets/SpellingBee/Scenes/SpellingBeeGame.unity +++ b/Assets/SpellingBee/Scenes/SpellingBeeGame.unity @@ -326,6 +326,141 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &229512365 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 229512366} + - component: {fileID: 229512368} + - component: {fileID: 229512367} + m_Layer: 5 + m_Name: Game Title + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &229512366 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 229512365} + 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: [] + m_Father: {fileID: 906197777} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: 0, y: -25} + m_SizeDelta: {x: 1200, y: 100} + m_Pivot: {x: 0.5, y: 1} +--- !u!114 &229512367 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 229512365} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, 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_text: Spelling Bee + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4279242768 + m_fontColor: {r: 0.0627451, g: 0.0627451, b: 0.0627451, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: 97690656 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 64 + m_fontSizeBase: 64 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 1 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &229512368 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 229512365} + m_CullTransparentMesh: 1 --- !u!1 &519420028 GameObject: m_ObjectHideFlags: 0 @@ -1047,7 +1182,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8299246693487308515, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3} propertyPath: m_RootOrder - value: 7 + value: 8 objectReference: {fileID: 0} - target: {fileID: 8299246693487308515, guid: 3bccdf365a4fbea4d8fa1aa461d3dc5c, type: 3} propertyPath: m_AnchorMax.x @@ -1164,7 +1299,7 @@ RectTransform: - {fileID: 1761838460} - {fileID: 862382568} m_Father: {fileID: 906197777} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} @@ -1221,7 +1356,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5aa929dce1f59b340b4a0cca1bb68edc, type: 3} m_Name: m_EditorClassIdentifier: - userList: {fileID: 11400000, guid: 072bec636a40f7e4e93b0ac624a3bda2, type: 2} endText: {fileID: 1502459770} lpmText: {fileID: 1172084829} lettersRightText: {fileID: 994850063} @@ -1575,6 +1709,7 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 229512366} - {fileID: 1743003086} - {fileID: 1338727893} - {fileID: 1346005056} @@ -1646,7 +1781,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4318122119930585316, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} propertyPath: m_RootOrder - value: 5 + value: 6 objectReference: {fileID: 0} - target: {fileID: 4318122119930585316, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} propertyPath: m_AnchorMax.x @@ -1702,11 +1837,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 4318122119930585316, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} propertyPath: m_AnchoredPosition.x - value: -200 + value: -298 objectReference: {fileID: 0} - target: {fileID: 4318122119930585316, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} propertyPath: m_AnchoredPosition.y - value: -600 + value: -644 objectReference: {fileID: 0} - target: {fileID: 4318122119930585316, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -1728,6 +1863,22 @@ PrefabInstance: propertyPath: m_Name value: Feedback objectReference: {fileID: 0} + - target: {fileID: 4318122120222767928, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} + propertyPath: m_fontColor.b + value: 0.23921569 + objectReference: {fileID: 0} + - target: {fileID: 4318122120222767928, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} + propertyPath: m_fontColor.g + value: 0.28627452 + objectReference: {fileID: 0} + - target: {fileID: 4318122120222767928, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} + propertyPath: m_fontColor.r + value: 0.9607843 + objectReference: {fileID: 0} + - target: {fileID: 4318122120222767928, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} + propertyPath: m_fontColor32.rgba + value: 4280295456 + objectReference: {fileID: 0} - target: {fileID: 4318122120334233317, guid: 7c71c65ecb5fe0449a8b0d178987f016, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -3012,12 +3163,12 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 906197777} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -325, y: -300} - m_SizeDelta: {x: 250, y: 250} + m_AnchoredPosition: {x: -1200, y: -400} + m_SizeDelta: {x: 400, y: 400} m_Pivot: {x: 1, y: 1} --- !u!1 &1346005055 GameObject: @@ -3049,11 +3200,11 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 906197777} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0} m_AnchorMax: {x: 0.5, y: 0} - m_AnchoredPosition: {x: 0, y: 75} + m_AnchoredPosition: {x: 0, y: 125} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0} --- !u!114 &1346005057 @@ -3608,7 +3759,7 @@ MonoBehaviour: m_EditorClassIdentifier: signPredictor: {fileID: 1592592444} themeList: {fileID: 11400000, guid: a247e2ce790f0f746a3bc521e6ab7d58, type: 2} - userList: {fileID: 11400000, guid: 072bec636a40f7e4e93b0ac624a3bda2, type: 2} + fingerspelling: {fileID: 11400000, guid: e02921b294fdad940b6e4d57e716d3bf, type: 2} minigame: {fileID: 11400000, guid: 8a087d241d652634eb4f6352267ea7dc, type: 2} minigamelist: {fileID: 11400000, guid: 51453f9b41bc72f468ba3e67ab622f8f, type: 2} letterPrefab: {fileID: 4639383499500021565, guid: c3e66e8957864914cb022af914df6a28, type: 3} @@ -3986,7 +4137,6 @@ MonoBehaviour: modelInfoFile: {fileID: 4900000, guid: fb8b51022bdcd654a9f29c054832a1b5, type: 3} configAsset: {fileID: 4900000, guid: 6288c43cdca97374782dac1ea87aa029, type: 3} screen: {fileID: 1743003084} - screen2: {fileID: 0} --- !u!4 &1592592445 Transform: m_ObjectHideFlags: 0 @@ -4199,16 +4349,16 @@ RectTransform: m_GameObject: {fileID: 1743003083} 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_LocalScale: {x: 0.75, y: 0.75, z: 0.75} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 906197777} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 200, y: -300} - m_SizeDelta: {x: 960, y: 540} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 53, y: 382} + m_SizeDelta: {x: 900, y: 600} m_Pivot: {x: 0, y: 1} --- !u!1 &1754130535 GameObject: @@ -4652,11 +4802,11 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 906197777} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1} - m_AnchoredPosition: {x: 0, y: -50} + m_AnchoredPosition: {x: -458, y: -153} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1812475782 @@ -4884,11 +5034,11 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 906197777} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1} - m_AnchoredPosition: {x: 0, y: -100} + m_AnchoredPosition: {x: -458, y: -203} m_SizeDelta: {x: 300, y: 150} m_Pivot: {x: 0.5, y: 1} --- !u!1 &1898716846 diff --git a/Assets/SpellingBee/Scripts/SpellingBeeController.cs b/Assets/SpellingBee/Scripts/SpellingBeeController.cs index e6e5336..10a205a 100644 --- a/Assets/SpellingBee/Scripts/SpellingBeeController.cs +++ b/Assets/SpellingBee/Scripts/SpellingBeeController.cs @@ -50,6 +50,11 @@ public partial class SpellingBeeController : AbstractFeedback /// private bool gameEnded; + /// + /// List of learnables to get the threshold for the letters + /// + public Theme fingerspelling; + /// /// Amount of seconds user gets per letter of the current word /// Set to 1 for testing; should be increased later @@ -389,12 +394,12 @@ public partial class SpellingBeeController : AbstractFeedback if (successful) { correctLetters++; - letters[letterIndex].GetComponent().color = Color.green; + letters[letterIndex].GetComponent().color = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f); } else { incorrectLetters++; - letters[letterIndex].GetComponent().color = new Color(0.5f, 0.0f, 0.0f); + letters[letterIndex].GetComponent().color = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f); } do @@ -405,7 +410,7 @@ public partial class SpellingBeeController : AbstractFeedback // Change the color of the next letter or change to new word if (letterIndex < currentWord.Length) { - letters[letterIndex].GetComponent().color = Color.yellow; + letters[letterIndex].GetComponent().color = new Color(0x9f / 255.0f, 0xe7 / 255.0f, 0xf5 / 255.0f); } else { @@ -451,7 +456,7 @@ public partial class SpellingBeeController : AbstractFeedback // Dynamically load appearance char c = Char.ToUpper(word[i]); Image background = instance.GetComponent(); - background.color = i == 0 ? Color.yellow : c != ' ' ? Color.red : Color.clear; + background.color = i == 0 ? new Color(0x9f / 255.0f, 0xe7 / 255.0f, 0xf5 / 255.0f) : Color.clear; TMP_Text txt = instance.GetComponentInChildren(); txt.text = Char.ToString(c); } @@ -467,6 +472,17 @@ public partial class SpellingBeeController : AbstractFeedback yield return new WaitForSecondsRealtime(2); } + /// + /// Get the threshold for a given sign + /// + /// + /// + private float GetTresholdPercentage(string sign) + { + Learnable letter = fingerspelling.learnables.Find(l => l.name == sign); + return letter.thresholdPercentage; + } + /// /// The updateFunction that is called when new probabilities become available /// @@ -479,32 +495,45 @@ public partial class SpellingBeeController : AbstractFeedback if (signPredictor != null && signPredictor.learnableProbabilities != null && currentSign != null && signPredictor.learnableProbabilities.ContainsKey(currentSign)) { - float accuracy = signPredictor.learnableProbabilities[currentSign]; + float accCurrentSign = signPredictor.learnableProbabilities[currentSign]; + float thresholdCurrentSign = GetTresholdPercentage(currentSign); + + // Get highest predicted sign + string predictedSign = signPredictor.learnableProbabilities.Aggregate((a, b) => a.Value > b.Value ? a : b).Key; + float accPredictSign = signPredictor.learnableProbabilities[predictedSign]; + float thresholdPredictedSign = GetTresholdPercentage(predictedSign); + if (feedbackText != null && feedbackProgressImage != null) { - if (accuracy > 0.90) + Color col; + if (accCurrentSign > thresholdCurrentSign) { feedbackText.text = "Goed"; - feedbackText.color = Color.green; - feedbackProgressImage.color = Color.green; + col = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f); } - else if (accuracy > 0.80) + else if (accCurrentSign > 0.9 * thresholdCurrentSign) { feedbackText.text = "Bijna..."; - Color col = new Color(0xff / 255.0f, 0x66 / 255.0f, 0x00 / 255.0f); - feedbackText.color = col; - feedbackProgressImage.color = col; + col = new Color(0xf2 / 255.0f, 0x7f / 255.0f, 0x0c / 255.0f); + } + else if (accPredictSign > thresholdPredictedSign) + { + feedbackText.text = $"Verkeerde gebaar: '{predictedSign}'"; + col = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f); + accCurrentSign = 0.0f; } else { feedbackText.text = "Detecteren..."; - feedbackText.color = Color.red; - feedbackProgressImage.color = Color.red; + col = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f); } + feedbackText.color = col; + feedbackProgressImage.color = col; + float oldValue = feedbackProgress.value; // use an exponential scale - float newValue = Mathf.Exp(4 * (accuracy - 1.0f)); + float newValue = Mathf.Exp(4 * (accCurrentSign - 1.0f)); feedbackProgress.gameObject.Tween("FeedbackUpdate", oldValue, newValue, 0.2f, TweenScaleFunctions.CubicEaseInOut, (t) => { if (feedbackProgress != null) @@ -514,39 +543,35 @@ public partial class SpellingBeeController : AbstractFeedback }); } - // Check whether (in)correct sign has high accuracy - foreach (var kv in signPredictor.learnableProbabilities) + + if (accPredictSign > thresholdPredictedSign) { - if (kv.Value > 0.90) + // Correct sign + if (predictedSign == currentSign) { - predictedSign = kv.Key; - // Correct sign - if (predictedSign == currentSign) + yield return new WaitForSeconds(1.0f); + PredictSign(predictedSign); + timer = DateTime.Now; + predictedSign = null; + previousIncorrectSign = null; + } + // Incorrect sign + else + { + if (previousIncorrectSign != predictedSign) { - yield return new WaitForSeconds(1.0f); - predictSign(predictedSign); + timer = DateTime.Now; + previousIncorrectSign = predictedSign; + } + else if (DateTime.Now - timer > TimeSpan.FromSeconds(2.0f)) + { + PredictSign(predictedSign); timer = DateTime.Now; predictedSign = null; previousIncorrectSign = null; } - // Incorrect sign - else - { - if (previousIncorrectSign != predictedSign) - { - timer = DateTime.Now; - previousIncorrectSign = predictedSign; - } - else if (DateTime.Now - timer > TimeSpan.FromSeconds(2.0f)) - { - predictSign(predictedSign); - timer = DateTime.Now; - predictedSign = null; - previousIncorrectSign = null; - } - } - break; } + } } else if (feedbackProgress != null) @@ -572,7 +597,7 @@ public partial class SpellingBeeController : AbstractFeedback /// Function to confirm your prediction and check if it is correct. /// /// - public void predictSign(string sign) + public void PredictSign(string sign) { bool successful = sign.ToUpper() == currentWord[letterIndex].ToString().ToUpper(); if (successful)