Skip to content

Commit

Permalink
feat(clock): show date
Browse files Browse the repository at this point in the history
  • Loading branch information
Misaka-L committed Nov 1, 2024
1 parent efec5b4 commit 8945f39
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class Clock : UdonSharpBehaviour {
[HideInInspector] [UdonSynced] [SerializeField] private float _chronoOffsetTime;
[HideInInspector] [UdonSynced] [SerializeField] private bool _isChronoRunning;

[HideInInspector] [UdonSynced] [SerializeField] private bool _isDateShow;

[PublicAPI]
public void _OnInit() {
if (Networking.IsOwner(gameObject)) _ResetChrono();
Expand All @@ -32,8 +34,14 @@ public void _OnLostPower() {
private void LateUpdate() {
var currentDateTime = DateTime.UtcNow;

_dateTimeText.text = currentDateTime.ToString("HH:MM");
_secondYearText.text = currentDateTime.ToString("ss");
if (_isDateShow) {
_dateTimeText.text = currentDateTime.ToString("MM:dd");
_secondYearText.text = currentDateTime.ToString("yy");
}
else {
_dateTimeText.text = currentDateTime.ToString("HH:MM");
_secondYearText.text = currentDateTime.ToString("ss");
}

if (float.IsNaN(_chronoStartTime)) {
_chronoText.text = "";
Expand Down Expand Up @@ -90,5 +98,14 @@ private void _TakeOwnership() {
if (Networking.IsOwner(gameObject)) return;
Networking.SetOwner(Networking.LocalPlayer, gameObject);
}

[PublicAPI]
public void _ToggleDate() {
_TakeOwnership();

_isDateShow = !_isDateShow;

RequestSerialization();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48175,6 +48175,7 @@ Transform:
m_Children:
- {fileID: 3691487593711279355}
- {fileID: 4785755772916647149}
- {fileID: 3846737398644536512}
m_Father: {fileID: 6201961823668611207}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3066462451155329133
Expand Down Expand Up @@ -63616,6 +63617,116 @@ Transform:
- {fileID: 5041555298105131643}
m_Father: {fileID: 5828276618077622785}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &4603785348176206502
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3846737398644536512}
- component: {fileID: 6798902213543827725}
- component: {fileID: 2556402753523877529}
- component: {fileID: 46158173117493365}
m_Layer: 27
m_Name: ToggleDateButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3846737398644536512
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4603785348176206502}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.1477, y: 1.605, z: 11.874}
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1023587924125399084}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &6798902213543827725
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4603785348176206502}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 1
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &2556402753523877529
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4603785348176206502}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6effb45436024fa4e83a0b5f933b29b3, type: 3}
m_Name:
m_EditorClassIdentifier:
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes: []
_udonSharpBackingUdonBehaviour: {fileID: 46158173117493365}
controlName: Toggle Date
_targetBehaviour: {fileID: 4096691667790793828}
_leftClickEventName: _ToggleDate
_rightClickEventName:
_middleClickEventName:
_scrollUpEventName:
_scrollDownEventName:
--- !u!114 &46158173117493365
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4603785348176206502}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
m_Name:
m_EditorClassIdentifier:
interactTextPlacement: {fileID: 0}
interactText: Use
interactTextGO: {fileID: 0}
proximity: 2
SynchronizePosition: 0
AllowCollisionOwnershipTransfer: 0
Reliable: 0
_syncMethod: 0
serializedProgramAsset: {fileID: 11400000, guid: 29d4ae005176b804facc1191240b9de2,
type: 2}
programSource: {fileID: 11400000, guid: 6740a87533fb9214082ee378ad845cb9, type: 2}
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAE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QcF
publicVariablesUnityEngineObjects: []
publicVariablesSerializationDataFormat: 0
--- !u!1 &4649262741577984520
GameObject:
m_ObjectHideFlags: 0
Expand Down

0 comments on commit 8945f39

Please sign in to comment.