update timer to digital clock and improve timer layout

This commit is contained in:
Shavira 2025-05-24 10:55:52 +07:00
parent 39d64d7d6b
commit 3c5152143f
5 changed files with 2303 additions and 1010 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,19 +25,19 @@ RectTransform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1037614129} m_GameObject: {fileID: 1037614129}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 1550409469590064430} m_Father: {fileID: 2208555612532628297}
m_RootOrder: 3 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1} m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: -0.000061035156, y: 0} m_AnchoredPosition: {x: 0.000030517578, y: 0}
m_SizeDelta: {x: 100, y: 100} m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 1, y: 1} m_Pivot: {x: 0, y: 0.5}
--- !u!222 &1037614132 --- !u!222 &1037614132
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -59,7 +59,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0.9058824, g: 0.75294125, b: 0.92549026, a: 1} m_Color: {r: 0.9058824, g: 0.75294125, b: 0.92549026, a: 0}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -466,7 +466,7 @@ RectTransform:
- {fileID: 1550409470208135962} - {fileID: 1550409470208135962}
- {fileID: 1550409469179384916} - {fileID: 1550409469179384916}
- {fileID: 1550409469596184010} - {fileID: 1550409469596184010}
- {fileID: 1037614130} - {fileID: 2208555612532628297}
- {fileID: 6656031384333258019} - {fileID: 6656031384333258019}
m_Father: {fileID: 6994134417103467742} m_Father: {fileID: 6994134417103467742}
m_RootOrder: 1 m_RootOrder: 1
@ -1010,6 +1010,85 @@ CanvasGroup:
m_Interactable: 1 m_Interactable: 1
m_BlocksRaycasts: 1 m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0 m_IgnoreParentGroups: 0
--- !u!1 &3349297268055171621
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2208555612532628297}
- component: {fileID: 7393069600890364427}
- component: {fileID: 7693619216955287818}
m_Layer: 5
m_Name: Timer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2208555612532628297
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3349297268055171621}
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: 1037614130}
- {fileID: 9054757306045193920}
- {fileID: 5246482454647738308}
m_Father: {fileID: 1550409469590064430}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 242, y: 25}
m_SizeDelta: {x: 242.1106, y: 100}
m_Pivot: {x: 1, y: 1}
--- !u!222 &7393069600890364427
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3349297268055171621}
m_CullTransparentMesh: 1
--- !u!114 &7693619216955287818
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3349297268055171621}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 21300000, guid: 03da769f7cb3f492787dc8e96c5b404e, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5220425109258636578 --- !u!1 &5220425109258636578
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1086,6 +1165,217 @@ MonoBehaviour:
m_FillOrigin: 0 m_FillOrigin: 0
m_UseSpriteMesh: 0 m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1 m_PixelsPerUnitMultiplier: 1
--- !u!1 &5350299759567241944
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5246482454647738308}
- component: {fileID: 2250016864142405783}
- component: {fileID: 313379630598033789}
m_Layer: 5
m_Name: Timer Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5246482454647738308
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5350299759567241944}
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: 2208555612532628297}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 29.4, y: 1.2}
m_SizeDelta: {x: 67.1891, y: 67.1891}
m_Pivot: {x: 0, y: 0.5}
--- !u!222 &2250016864142405783
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5350299759567241944}
m_CullTransparentMesh: 1
--- !u!114 &313379630598033789
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5350299759567241944}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 21300000, guid: 783b1dc9547a84c909f164efa26ab3fb, type: 3}
m_Type: 3
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &6629437727233844528
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9054757306045193920}
- component: {fileID: 7862771948574635227}
- component: {fileID: 760767126207873636}
m_Layer: 5
m_Name: Time Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &9054757306045193920
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6629437727233844528}
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: 2208555612532628297}
m_RootOrder: 1
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: 62.448605, y: 0}
m_SizeDelta: {x: 148.1394, y: 88.5835}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7862771948574635227
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6629437727233844528}
m_CullTransparentMesh: 1
--- !u!114 &760767126207873636
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6629437727233844528}
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: 48
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 9fa5016cb7e534c0aa0c0adb2ecf9124, type: 2}
m_sharedMaterial: {fileID: 6098576539282327867, guid: 9fa5016cb7e534c0aa0c0adb2ecf9124, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4278190080
m_fontColor: {r: 0, g: 0, b: 0, 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: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
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: 16.530647, 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!1 &6656031382942894465 --- !u!1 &6656031382942894465
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -3024,6 +3314,7 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
questionText: {fileID: 6656031383329993839} questionText: {fileID: 6656031383329993839}
currentQuestion: {fileID: 11400000, guid: 8fb143c91548cb04da122f9042763287, type: 2} currentQuestion: {fileID: 11400000, guid: 8fb143c91548cb04da122f9042763287, type: 2}
normalButttonSprite: {fileID: 21300000, guid: b0eb9c535328048ca85e8a9f5088e776, type: 3}
trueAnswerSprite: {fileID: 21300000, guid: b32a6d84afc984b61b05b20c3d44569b, type: 3} trueAnswerSprite: {fileID: 21300000, guid: b32a6d84afc984b61b05b20c3d44569b, type: 3}
falseAnswerSprite: {fileID: 21300000, guid: e6404ce3667f546569c1c59a6de9495d, type: 3} falseAnswerSprite: {fileID: 21300000, guid: e6404ce3667f546569c1c59a6de9495d, type: 3}
answerButtons: answerButtons:
@ -3032,10 +3323,11 @@ MonoBehaviour:
- {fileID: 6656031384000762742} - {fileID: 6656031384000762742}
- {fileID: 6656031382942894465} - {fileID: 6656031382942894465}
timerImage: {fileID: 1037614131} timerImage: {fileID: 1037614131}
timerText: {fileID: 760767126207873636}
gameManager: {fileID: 0} gameManager: {fileID: 0}
dataManager: {fileID: 0} dataManager: {fileID: 0}
isComplete: 0 isComplete: 0
timeToCompleteQuestion: 10 timeToCompleteQuestion: 30
timeToShowCorrectAnswer: 2 timeToShowCorrectAnswer: 2
loadNextQuestion: 0 loadNextQuestion: 0
fillFraction: 0 fillFraction: 0

View File

@ -13,6 +13,7 @@ public class QuizPopUp : Menu<QuizPopUp>
[SerializeField] QuestionSO currentQuestion; [SerializeField] QuestionSO currentQuestion;
[Header("Answers")] [Header("Answers")]
[SerializeField] private Sprite normalButttonSprite;
[SerializeField] private Sprite trueAnswerSprite; [SerializeField] private Sprite trueAnswerSprite;
[SerializeField] private Sprite falseAnswerSprite; [SerializeField] private Sprite falseAnswerSprite;
[SerializeField] GameObject[] answerButtons; [SerializeField] GameObject[] answerButtons;
@ -21,7 +22,7 @@ public class QuizPopUp : Menu<QuizPopUp>
[Header("Timer")] [Header("Timer")]
[SerializeField] Image timerImage; [SerializeField] Image timerImage;
[SerializeField] TextMeshProUGUI timerText;
public GameManager gameManager; public GameManager gameManager;
public DataManager dataManager; public DataManager dataManager;
@ -115,7 +116,20 @@ public class QuizPopUp : Menu<QuizPopUp>
public void UpdateTimer() public void UpdateTimer()
{ {
timerValue -= Time.deltaTime; timerValue -= Time.deltaTime;
timerValue = Mathf.Max(timerValue, 0);
int hours = Mathf.FloorToInt(timerValue / 3600);
int minutes = Mathf.FloorToInt((timerValue % 3600) / 60);
int seconds = Mathf.FloorToInt(timerValue % 60);
if (hours > 0)
{
timerText.text = string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
}
else
{
timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
}
if (isAnsweringQuestion) if (isAnsweringQuestion)
{ {
if (timerValue > 0) if (timerValue > 0)
@ -204,12 +218,16 @@ public class QuizPopUp : Menu<QuizPopUp>
void DisplayQuestion() void DisplayQuestion()
{ {
Image buttonImage;
questionText.text = currentQuestion.question; questionText.text = currentQuestion.question;
for (int i = 0; i < answerButtons.Length; i++) for (int i = 0; i < answerButtons.Length; i++)
{ {
buttonImage = answerButtons[i].GetComponent<Image>();
buttonImage.sprite = normalButttonSprite;
TextMeshProUGUI buttonText = answerButtons[i].GetComponentInChildren<TextMeshProUGUI>(); TextMeshProUGUI buttonText = answerButtons[i].GetComponentInChildren<TextMeshProUGUI>();
buttonText.text = currentQuestion.answers[i]; buttonText.text = currentQuestion.answers[i];
} }
} }