Working on networkmanager
This commit is contained in:
@@ -10822,6 +10822,164 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||
m_PrefabInstance: {fileID: 742161192}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &357748365
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 357748370}
|
||||
- component: {fileID: 357748369}
|
||||
- component: {fileID: 357748368}
|
||||
- component: {fileID: 357748367}
|
||||
- component: {fileID: 357748371}
|
||||
- component: {fileID: 357748366}
|
||||
m_Layer: 0
|
||||
m_Name: BallUnityDt
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &357748366
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 2
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 357748365}
|
||||
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: 2
|
||||
serializedProgramAsset: {fileID: 11400000, guid: 8968388b0e4fe434fb8da62328c108a0, type: 2}
|
||||
programSource: {fileID: 11400000, guid: 1845851c6c8f8254baa6b40646c66d59, type: 2}
|
||||
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
|
||||
publicVariablesUnityEngineObjects: []
|
||||
publicVariablesSerializationDataFormat: 0
|
||||
--- !u!135 &357748367
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 357748365}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 0.5
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &357748368
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 357748365}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: d77dfda7d2b90ea4983b8659e2c6c0e9, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &357748369
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 357748365}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &357748370
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 357748365}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.426, y: 0, z: -0.468}
|
||||
m_LocalScale: {x: 0.05, y: 0.05, z: 0.05}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1003947896}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &357748371
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 357748365}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0980d82a15346eb45b49fd33db0ffee9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes: []
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 357748366}
|
||||
networkManager: {fileID: 1200574210}
|
||||
start: {fileID: 992156376}
|
||||
end: {fileID: 312606797}
|
||||
mode: 2
|
||||
--- !u!1001 &358677456
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -15974,6 +16132,164 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1315692994360949719, guid: 00a825a5aeafee94789192f61cbb3a5a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1229682176}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &527776389
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 527776395}
|
||||
- component: {fileID: 527776394}
|
||||
- component: {fileID: 527776393}
|
||||
- component: {fileID: 527776392}
|
||||
- component: {fileID: 527776391}
|
||||
- component: {fileID: 527776390}
|
||||
m_Layer: 0
|
||||
m_Name: BallDt
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &527776390
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 2
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 527776389}
|
||||
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: 2
|
||||
serializedProgramAsset: {fileID: 11400000, guid: 8968388b0e4fe434fb8da62328c108a0, type: 2}
|
||||
programSource: {fileID: 11400000, guid: 1845851c6c8f8254baa6b40646c66d59, type: 2}
|
||||
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
|
||||
publicVariablesUnityEngineObjects: []
|
||||
publicVariablesSerializationDataFormat: 0
|
||||
--- !u!114 &527776391
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 527776389}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0980d82a15346eb45b49fd33db0ffee9, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes: []
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 527776390}
|
||||
networkManager: {fileID: 1200574210}
|
||||
start: {fileID: 992156376}
|
||||
end: {fileID: 312606797}
|
||||
mode: 1
|
||||
--- !u!135 &527776392
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 527776389}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Radius: 0.5
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &527776393
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 527776389}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 27754be47f0109d4ebd0238a3abcab08, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &527776394
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 527776389}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &527776395
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 527776389}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.426, y: 0, z: -0.468}
|
||||
m_LocalScale: {x: 0.05, y: 0.05, z: 0.05}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1003947896}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &528223655 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6416098964784429726, guid: f10209aafcd484f438cbd0888287e98a, type: 3}
|
||||
@@ -29662,6 +29978,8 @@ Transform:
|
||||
- {fileID: 992156376}
|
||||
- {fileID: 312606797}
|
||||
- {fileID: 1156754001}
|
||||
- {fileID: 527776395}
|
||||
- {fileID: 357748370}
|
||||
m_Father: {fileID: 696593979}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1006088012
|
||||
@@ -33439,6 +33757,30 @@ MonoBehaviour:
|
||||
m_StringArgument: SyncButtonPressed
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 527776390}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName: SendCustomEvent
|
||||
m_Mode: 5
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: SyncButtonPressed
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 357748366}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName: SendCustomEvent
|
||||
m_Mode: 5
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: SyncButtonPressed
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &1106884489
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -35181,7 +35523,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 2100000, guid: 0dd5569666c2c954da72d06b96c639f0, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
@@ -35261,6 +35603,7 @@ MonoBehaviour:
|
||||
networkManager: {fileID: 1200574210}
|
||||
start: {fileID: 992156376}
|
||||
end: {fileID: 312606797}
|
||||
mode: 0
|
||||
--- !u!1 &1156762256
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -36706,6 +37049,8 @@ MonoBehaviour:
|
||||
_udonSharpBackingUdonBehaviour: {fileID: 1200574209}
|
||||
syncedObjects:
|
||||
- {fileID: 1156754006}
|
||||
- {fileID: 527776391}
|
||||
- {fileID: 357748371}
|
||||
DebugImageToIndicateOwner: {fileID: 1745114900}
|
||||
--- !u!1 &1203813879
|
||||
GameObject:
|
||||
@@ -52447,6 +52792,30 @@ MonoBehaviour:
|
||||
m_StringArgument: UpButtonPressed
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 527776390}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName: SendCustomEvent
|
||||
m_Mode: 5
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: UpButtonPressed
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 357748366}
|
||||
m_TargetAssemblyTypeName:
|
||||
m_MethodName: SendCustomEvent
|
||||
m_Mode: 5
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument: UpButtonPressed
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &1745114898
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -52829,6 +53198,9 @@ MonoBehaviour:
|
||||
DynamicPrefabs: []
|
||||
DynamicMaterials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 2100000, guid: d77dfda7d2b90ea4983b8659e2c6c0e9, type: 2}
|
||||
- {fileID: 2100000, guid: 27754be47f0109d4ebd0238a3abcab08, type: 2}
|
||||
- {fileID: 2100000, guid: 0dd5569666c2c954da72d06b96c639f0, type: 2}
|
||||
- {fileID: 2100000, guid: db2b6d76bdd134244912a5c1c9971804, type: 2}
|
||||
LightMapsNear: []
|
||||
LightMapsFar: []
|
||||
@@ -54044,6 +54416,14 @@ MonoBehaviour:
|
||||
ID: 305
|
||||
SerializedTypeNames:
|
||||
- VRC.Udon.UdonBehaviour
|
||||
- gameObject: {fileID: 527776389}
|
||||
ID: 306
|
||||
SerializedTypeNames:
|
||||
- VRC.Udon.UdonBehaviour
|
||||
- gameObject: {fileID: 357748365}
|
||||
ID: 307
|
||||
SerializedTypeNames:
|
||||
- VRC.Udon.UdonBehaviour
|
||||
portraitCameraPositionOffset: {x: 0, y: 0, z: 0}
|
||||
portraitCameraRotationOffset: {x: 0, y: 1, z: 0, w: -0.00000004371139}
|
||||
PlayerPersistence: []
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -88,7 +88,7 @@ namespace Marro.PacManUdon
|
||||
StartAttractMode();
|
||||
}
|
||||
|
||||
public override void FixedUpdate()
|
||||
public override void SyncedUpdate()
|
||||
{
|
||||
TimeSequenceUpdate(Time.deltaTime);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -150,7 +150,7 @@ namespace Marro.PacManUdon
|
||||
// Debug.Log($"{gameObject} reset with state: {state}, target: {target}, offGrid: {offGrid}");
|
||||
}
|
||||
|
||||
public override void FixedUpdate()
|
||||
public override void SyncedUpdate()
|
||||
{
|
||||
if (ghostType == PacManGhostType.Blinky)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 11
|
||||
Data: 15
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -277,19 +277,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: startTimeTicks
|
||||
Data: offsetTime
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: startTimeTicks
|
||||
Data: offsetTime
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 17|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int64, mscorlib
|
||||
Data: System.Single, mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@@ -331,13 +331,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: nextEventTimeTicks
|
||||
Data: internalTime
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: nextEventTimeTicks
|
||||
Data: internalTime
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
@@ -379,16 +379,64 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: retriesWithoutSuccess
|
||||
Data: nextEventTime
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: nextEventTime
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: retriesWithoutSuccess
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: retriesWithoutSuccess
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 22|System.RuntimeType, mscorlib
|
||||
Data: 24|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32, mscorlib
|
||||
@@ -397,7 +445,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 22
|
||||
Data: 24
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -412,7 +460,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -436,13 +484,13 @@ MonoBehaviour:
|
||||
Data: buffer
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: buffer
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 25|System.RuntimeType, mscorlib
|
||||
Data: 27|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Byte[], mscorlib
|
||||
@@ -451,55 +499,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: index
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: index
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 22
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 22
|
||||
Data: 27
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -535,19 +535,67 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: networkedData
|
||||
Data: bufferIndex
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: bufferIndex
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 24
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 24
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: networkedData
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: networkedData
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
Data: 27
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
Data: 27
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -562,13 +610,13 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 31|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
||||
Data: 33|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@@ -589,13 +637,61 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <CurrentTimeTicks>k__BackingField
|
||||
Data: <Ready>k__BackingField
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 32|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <CurrentTimeTicks>k__BackingField
|
||||
Data: <Ready>k__BackingField
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 12
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 12
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 35|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <SyncedTime>k__BackingField
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <SyncedTime>k__BackingField
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
@@ -616,7 +712,103 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 37|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <Dt>k__BackingField
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <Dt>k__BackingField
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <IsEventUpdate>k__BackingField
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <IsEventUpdate>k__BackingField
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 12
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 12
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 41|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
|
||||
@@ -37,38 +37,146 @@ namespace Marro.PacManUdon
|
||||
// [6]: (byte) Type of event. 0 = Full Sync, which is used to sync up from an undefinted state.
|
||||
// [7+]: Event-specific data
|
||||
|
||||
#region Constants
|
||||
/// <summary>
|
||||
/// The maximum size of the buffer in bytes.
|
||||
/// </summary>
|
||||
private const int BufferMaxSizeBytes = 10000;
|
||||
/// <summary>
|
||||
/// How many bytes to increase the buffer size by if the current one is not enough.
|
||||
/// </summary>
|
||||
private const int BufferIncrementSizeBytes = 1000;
|
||||
|
||||
[SerializeField] private SyncedObject[] syncedObjects;
|
||||
|
||||
[SerializeField] private Animator DebugImageToIndicateOwner;
|
||||
|
||||
private bool isOwner;
|
||||
private bool isSynced;
|
||||
|
||||
private long startTimeTicks = DateTime.UtcNow.Ticks; // Initialize to prevent errors
|
||||
private long nextEventTimeTicks;
|
||||
|
||||
private int retriesWithoutSuccess;
|
||||
|
||||
// Main buffer of events
|
||||
private byte[] buffer;
|
||||
private int index;
|
||||
|
||||
/// <summary>
|
||||
/// The index in an event where the event size is stored.
|
||||
/// </summary>
|
||||
private const ushort HeaderEventSizeIndex = 0;
|
||||
/// <summary>
|
||||
/// The index in an event where the timestamp is stored.
|
||||
/// </summary>
|
||||
private const ushort HeaderTimestampIndex = 2;
|
||||
/// <summary>
|
||||
/// The index in an event where the event type is stored.
|
||||
/// </summary>
|
||||
private const ushort HeaderEventTypeIndex = 6;
|
||||
/// <summary>
|
||||
/// The total length of the header of an event, in bytes.
|
||||
/// </summary>
|
||||
private const ushort HeaderLength = 7;
|
||||
|
||||
private const int Delay = 250;
|
||||
/// <summary>
|
||||
/// The multiplier from Unity time to a timestamp.
|
||||
/// </summary>
|
||||
private const int TimestampMultiplier = 1000;
|
||||
/// <summary>
|
||||
/// The zero value of a timestamp. Anything below this value is negative.
|
||||
/// </summary>
|
||||
private const uint TimestampZeroValue = 1000;
|
||||
/// <summary>
|
||||
/// The delay at which the receiving side replays events.
|
||||
/// </summary>
|
||||
private const float Delay = 0.250f;
|
||||
#endregion
|
||||
|
||||
#region Private attributes
|
||||
/// <summary>
|
||||
/// Objects which are controlled by this <see cref="NetworkManager"/>.
|
||||
/// </summary>
|
||||
[SerializeField] private SyncedObject[] syncedObjects;
|
||||
|
||||
/// <summary>
|
||||
/// An animator which visualizes whether the current perspective is the owner.
|
||||
/// </summary>
|
||||
[SerializeField] private Animator DebugImageToIndicateOwner;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current perspective is the transmitting side.
|
||||
/// </summary>
|
||||
private bool isOwner;
|
||||
/// <summary>
|
||||
/// Whether the current perspective is synced with the owner. (Always true if current perspective is owner.)
|
||||
/// </summary>
|
||||
private bool isSynced;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Offset from system time to network time, including delay.
|
||||
/// </summary>
|
||||
private float offsetTime;
|
||||
/// <summary>
|
||||
/// Time since last full sync, captured when this FixedUpdate started, with network delay applied.
|
||||
/// </summary>
|
||||
private float internalTime;
|
||||
|
||||
/// <summary>
|
||||
/// Time at which next received event occured.
|
||||
/// </summary>
|
||||
private float nextEventTime;
|
||||
|
||||
/// <summary>
|
||||
/// Amounot of retries in a row without a successful sync.
|
||||
/// </summary>
|
||||
private int retriesWithoutSuccess;
|
||||
|
||||
/// <summary>
|
||||
/// Main buffer of data to be transmitted or processed
|
||||
/// </summary>
|
||||
private byte[] buffer;
|
||||
/// <summary>
|
||||
/// Index of <see cref="buffer"/>.
|
||||
/// </summary>
|
||||
private int bufferIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Data which is currently available on the network.
|
||||
/// </summary>
|
||||
[UdonSynced] private byte[] networkedData = new byte[0];
|
||||
#endregion
|
||||
|
||||
public long CurrentTimeTicks { get; private set; }
|
||||
#region Public fields
|
||||
/// <summary>
|
||||
/// Whether this <see cref="NetworkManager"/> is ready to transmit or receive data.
|
||||
/// If false, networking is disabled and this <see cref="NetworkManager"/> acts as a pass-through.
|
||||
/// </summary>
|
||||
public bool Ready { get; private set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// The time since last full sync which is currently being simulated.
|
||||
/// </summary>
|
||||
public float SyncedTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time since the last simulation, in seconds.
|
||||
/// </summary>
|
||||
public float Dt { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the current simulation to prepare for applying a network event?
|
||||
/// True = Yes, This update is preparing for a network update.
|
||||
/// False = No, this update is after the network update or there was no
|
||||
/// </summary>
|
||||
public bool IsEventUpdate { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Is the local user owner?
|
||||
/// </summary>
|
||||
public bool IsOwner => isOwner;
|
||||
#endregion
|
||||
|
||||
#region General
|
||||
public void Awake()
|
||||
{
|
||||
offsetTime = Time.fixedTime;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (Ready)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Already initialized, rejecting repeat call to {nameof(Initialize)}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
|
||||
@@ -77,328 +185,49 @@ namespace Marro.PacManUdon
|
||||
return;
|
||||
}
|
||||
|
||||
buffer = new byte[BufferIncrementSizeBytes];
|
||||
index = 0;
|
||||
startTimeTicks = DateTime.UtcNow.Ticks;
|
||||
isSynced = false;
|
||||
retriesWithoutSuccess = 0;
|
||||
SetOwner(Networking.IsOwner(gameObject));
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized, startTimeTicks: {startTimeTicks}");
|
||||
buffer = new byte[BufferIncrementSizeBytes];
|
||||
bufferIndex = 0;
|
||||
isSynced = isOwner; // Owner is always synced
|
||||
retriesWithoutSuccess = 0;
|
||||
|
||||
offsetTime = Time.fixedTime;
|
||||
internalTime = 0;
|
||||
SyncedTime = 0;
|
||||
Dt = Time.fixedDeltaTime;
|
||||
|
||||
Ready = true;
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized, time offset: {offsetTime}");
|
||||
}
|
||||
|
||||
public void Update()
|
||||
public void FixedUpdate()
|
||||
{
|
||||
UpdateInternalTime();
|
||||
|
||||
if (!isOwner)
|
||||
{
|
||||
ProgressReplayTime();
|
||||
ProgressEventTime();
|
||||
}
|
||||
|
||||
UpdateTime(DateTime.UtcNow.Ticks);
|
||||
PerformFixedSyncedUpdate();
|
||||
}
|
||||
|
||||
public void SendEvent(NetworkEventType eventType)
|
||||
public void UpdateInternalTime()
|
||||
{
|
||||
if (!isOwner)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEvent)} while not the owner!");
|
||||
return;
|
||||
}
|
||||
internalTime = Time.fixedTime - offsetTime;
|
||||
}
|
||||
|
||||
var eventTime = GetTimestamp(CurrentTimeTicks);
|
||||
|
||||
InitializeEvent(eventType, eventTime, BufferMaxSizeBytes, out byte[][] data, out var index);
|
||||
private void PerformFixedSyncedUpdate()
|
||||
{
|
||||
IsEventUpdate = false;
|
||||
ProgressSyncedTime(internalTime);
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
obj.AppendSyncedData(data, ref index, eventType);
|
||||
obj.SyncedUpdate();
|
||||
}
|
||||
|
||||
// Get event size, skipping over the event size which is not yet included
|
||||
ushort eventSize = 0;
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
eventSize += (ushort)data[i].Length;
|
||||
}
|
||||
|
||||
if (!EnsureSpaceToStoreEvent(eventSize))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
data[0] = BitConverter.GetBytes(eventSize);
|
||||
|
||||
var oldIndex = this.index;
|
||||
|
||||
FlattenAndCopy(data, index, buffer, ref this.index);
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event with {eventSize} bytes and timestamp {eventTime} for serialization, index went from {oldIndex} to {this.index}");
|
||||
|
||||
RequestSerialization();
|
||||
|
||||
retriesWithoutSuccess = 0; // We had success!
|
||||
}
|
||||
|
||||
public void RequestEvent(NetworkEventType eventType)
|
||||
{
|
||||
if (isOwner)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEvent)} while we are the owner!");
|
||||
return;
|
||||
}
|
||||
|
||||
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
|
||||
}
|
||||
|
||||
[NetworkCallable]
|
||||
public void RequestEventReceived(NetworkEventType eventType)
|
||||
{
|
||||
if (!isOwner)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEventReceived)} while we are not the owner!");
|
||||
return;
|
||||
}
|
||||
|
||||
SendEvent(eventType);
|
||||
}
|
||||
|
||||
private void ProcessIncomingData()
|
||||
{
|
||||
if (networkedData.Length == 0)
|
||||
{
|
||||
return; // Nothing to process
|
||||
}
|
||||
|
||||
var length = networkedData.Length;
|
||||
int index = 0;
|
||||
while (index < length)
|
||||
{
|
||||
if (length - index < HeaderLength)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(ProcessIncomingData)}: Remaining data in networkedData is not long enough to form a complete event!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
|
||||
var eventSize = networkedData[index + HeaderEventSizeIndex];
|
||||
var eventType = (NetworkEventType)networkedData[index + HeaderEventTypeIndex];
|
||||
|
||||
if (eventType == NetworkEventType.FullSync)
|
||||
{
|
||||
ProcessIncomingFullSync(index, eventSize); // Immediately process full sync
|
||||
index += eventSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isSynced)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received event of type {eventType} while we are not yet synced to the remote time, ignoring event.");
|
||||
index += eventSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
AppendEventToBuffer(index, eventSize);
|
||||
index += eventSize;
|
||||
}
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{BytesToString(networkedData)}");
|
||||
}
|
||||
|
||||
private void ProcessIncomingFullSync(int index, int size)
|
||||
{
|
||||
// Intentionally not doing a buffer size check here, since this is not appending to the buffer
|
||||
// (and there is no good way to continue if event is too large)
|
||||
|
||||
// Clear buffer and copy the full sync into it
|
||||
buffer = new byte[size];
|
||||
Array.Copy(networkedData, index, buffer, 0, size);
|
||||
this.index = size;
|
||||
|
||||
// Sync up to the time in the full sync
|
||||
var timestamp = BitConverter.ToUInt32(networkedData, index + HeaderTimestampIndex);
|
||||
SyncToTimestamp(timestamp);
|
||||
|
||||
// Immediately apply the full sync
|
||||
nextEventTimeTicks = GetTimeTicks(timestamp);
|
||||
isSynced = true;
|
||||
}
|
||||
|
||||
private void AppendEventToBuffer(int index, int size)
|
||||
{
|
||||
if (!EnsureSpaceToStoreEvent(size))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Array.Copy(networkedData, index, buffer, this.index, size);
|
||||
this.index += size;
|
||||
|
||||
UpdateNextEventTime();
|
||||
}
|
||||
|
||||
private void ProgressReplayTime()
|
||||
{
|
||||
while (index != 0 && nextEventTimeTicks <= CurrentTimeTicks)
|
||||
{
|
||||
ProcessIncomingEvent();
|
||||
UpdateNextEventTime();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateNextEventTime()
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var nextEventTimeTicks = GetTimeTicks(BitConverter.ToUInt32(buffer, HeaderTimestampIndex));
|
||||
if (nextEventTimeTicks >= this.nextEventTimeTicks)
|
||||
{
|
||||
this.nextEventTimeTicks = nextEventTimeTicks;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event is earlier than previous event!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessIncomingEvent()
|
||||
{
|
||||
var eventTimeTicks = GetTimeTicks(BitConverter.ToUInt32(buffer, HeaderTimestampIndex));
|
||||
var eventType = (NetworkEventType)buffer[HeaderEventTypeIndex];
|
||||
var index = (int)HeaderLength; // Skip header
|
||||
|
||||
UpdateTime(eventTimeTicks);
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
obj.FixedUpdate();
|
||||
}
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
var success = obj.SetSyncedData(buffer, ref index, eventType);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Malformed data reported by {obj.name} during event type {eventType}!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (index > this.index)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer overflow during {nameof(SyncedObject.SetSyncedData)} for {obj.name} in event type {eventType}!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var eventSize = BitConverter.ToUInt16(buffer, HeaderEventSizeIndex);
|
||||
if (index != eventSize)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Amount of data read does not match event size! Expected {eventSize}, read {index}.");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveProcessedDataFromBuffer(index);
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Processed incoming event! Total {index} bytes.");
|
||||
|
||||
retriesWithoutSuccess = 0; // We had success!
|
||||
}
|
||||
|
||||
private void SyncToTimestamp(uint newTime)
|
||||
{
|
||||
var timeToSyncTo = newTime - Delay;
|
||||
startTimeTicks = DateTime.UtcNow.Ticks - timeToSyncTo * TimeSpan.TicksPerMillisecond;
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to time {newTime}, startTimeTicks is now {startTimeTicks}");
|
||||
}
|
||||
|
||||
private bool EnsureSpaceToStoreEvent(int eventSize)
|
||||
{
|
||||
if (index + eventSize <= buffer.Length)
|
||||
{
|
||||
return true; // Enough space!
|
||||
}
|
||||
|
||||
var newBufferSize = ((index + eventSize) / BufferIncrementSizeBytes + 1) * BufferIncrementSizeBytes;
|
||||
|
||||
var success = IncreaseBufferSize(newBufferSize);
|
||||
if (success)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer is not large enough to store event!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store event!");
|
||||
}
|
||||
|
||||
HandleError(); // We can store event now that we cleared the buffer.
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IncreaseBufferSize(int newSize)
|
||||
{
|
||||
if (newSize < buffer.Length)
|
||||
{
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Cannot decrease the size of the buffer!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newSize > BufferMaxSizeBytes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var oldBuffer = buffer;
|
||||
buffer = new byte[newSize];
|
||||
oldBuffer.CopyTo(buffer, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void InitializeEvent(NetworkEventType eventType, uint eventTime, int maxSize, out byte[][] data, out int index)
|
||||
{
|
||||
data = new byte[maxSize][];
|
||||
index = 3;
|
||||
|
||||
data[0] = new byte[2]; // Placeholder for event size
|
||||
data[1] = BitConverter.GetBytes(eventTime);
|
||||
data[2] = new byte[] { GameManager.Int32ToByte((int)eventType) };
|
||||
}
|
||||
|
||||
private void FlattenAndCopy(byte[][] data, int length, byte[] target, ref int index)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
var values = data[i];
|
||||
Array.Copy(values, 0, target, index, values.Length);
|
||||
index += values.Length;
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveProcessedDataFromBuffer(int amountProcessed)
|
||||
{
|
||||
var oldBuffer = buffer;
|
||||
index -= amountProcessed;
|
||||
buffer = new byte[BufferMaxSizeBytes];
|
||||
Array.Copy(oldBuffer, amountProcessed, buffer, 0, index);
|
||||
}
|
||||
|
||||
private void ClearBuffer()
|
||||
{
|
||||
buffer = new byte[BufferMaxSizeBytes];
|
||||
index = 0;
|
||||
}
|
||||
|
||||
private void HandleError()
|
||||
@@ -436,7 +265,323 @@ namespace Marro.PacManUdon
|
||||
DebugImageToIndicateOwner.SetFloat("Color", isOwner ? 1 : 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Sender
|
||||
public void SendEvent(NetworkEventType eventType)
|
||||
{
|
||||
if (!isOwner)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEvent)} while not the owner!");
|
||||
return;
|
||||
}
|
||||
|
||||
var eventTime = TimeToTimestamp(SyncedTime);
|
||||
|
||||
InitializeEvent(eventType, eventTime, BufferMaxSizeBytes, out byte[][] data, out var index);
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
obj.AppendSyncedData(data, ref index, eventType);
|
||||
}
|
||||
|
||||
// Get event size, skipping over the event size which is not yet included
|
||||
ushort eventSize = 0;
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
eventSize += (ushort)data[i].Length;
|
||||
}
|
||||
|
||||
if (!EnsureSpaceToStoreEvent(eventSize))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
data[0] = BitConverter.GetBytes(eventSize);
|
||||
|
||||
var oldIndex = this.bufferIndex;
|
||||
|
||||
FlattenAndCopy(data, index, buffer, ref this.bufferIndex);
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event with {eventSize} bytes and timestamp {eventTime} for serialization, index went from {oldIndex} to {this.bufferIndex}");
|
||||
|
||||
RequestSerialization();
|
||||
|
||||
retriesWithoutSuccess = 0; // We had success!
|
||||
}
|
||||
|
||||
private static void InitializeEvent(NetworkEventType eventType, uint eventTime, int maxSize, out byte[][] data, out int index)
|
||||
{
|
||||
data = new byte[maxSize][];
|
||||
index = 3;
|
||||
|
||||
data[0] = new byte[2]; // Placeholder for event size
|
||||
data[1] = BitConverter.GetBytes(eventTime);
|
||||
data[2] = new byte[] { GameManager.Int32ToByte((int)eventType) };
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Receiver
|
||||
public void RequestEvent(NetworkEventType eventType)
|
||||
{
|
||||
if (isOwner)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEvent)} while we are the owner!");
|
||||
return;
|
||||
}
|
||||
|
||||
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
|
||||
}
|
||||
|
||||
private void ProcessIncomingData()
|
||||
{
|
||||
if (networkedData.Length == 0)
|
||||
{
|
||||
return; // Nothing to process
|
||||
}
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{BytesToString(networkedData)}");
|
||||
|
||||
var length = networkedData.Length;
|
||||
int index = 0;
|
||||
while (index < length)
|
||||
{
|
||||
if (length - index < HeaderLength)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(ProcessIncomingData)}: Remaining data in networkedData is not long enough to form a complete event!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
|
||||
var eventSize = networkedData[index + HeaderEventSizeIndex];
|
||||
var eventType = (NetworkEventType)networkedData[index + HeaderEventTypeIndex];
|
||||
|
||||
if (eventType == NetworkEventType.FullSync)
|
||||
{
|
||||
ProcessIncomingFullSync(index, eventSize); // Immediately process full sync
|
||||
index += eventSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isSynced)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received event of type {eventType} while we are not yet synced to the remote time, ignoring event.");
|
||||
index += eventSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
AppendEventToBuffer(index, eventSize);
|
||||
index += eventSize;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessIncomingFullSync(int index, int size)
|
||||
{
|
||||
// Intentionally not doing a buffer size check here, since this is not appending to the buffer
|
||||
// (and there is no good way to continue if event is too large)
|
||||
|
||||
// Clear buffer and copy the full sync into it
|
||||
buffer = new byte[size];
|
||||
Array.Copy(networkedData, index, buffer, 0, size);
|
||||
this.bufferIndex = size;
|
||||
|
||||
// Sync up to the time in the full sync
|
||||
var timestamp = BitConverter.ToUInt32(networkedData, index + HeaderTimestampIndex);
|
||||
SyncToTimestamp(timestamp);
|
||||
|
||||
// Immediately apply the full sync
|
||||
UpdateNextEventTime();
|
||||
isSynced = true;
|
||||
}
|
||||
|
||||
private void ProgressEventTime()
|
||||
{
|
||||
IsEventUpdate = true;
|
||||
|
||||
while (bufferIndex != 0 && nextEventTime <= internalTime)
|
||||
{
|
||||
ProcessIncomingEvent();
|
||||
UpdateNextEventTime();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessIncomingEvent()
|
||||
{
|
||||
var eventTime = TimestampToTime(BitConverter.ToUInt32(buffer, HeaderTimestampIndex));
|
||||
var eventType = (NetworkEventType)buffer[HeaderEventTypeIndex];
|
||||
var index = (int)HeaderLength; // Skip header
|
||||
|
||||
ProgressSyncedTime(eventTime);
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
obj.SyncedUpdate();
|
||||
}
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
var success = obj.SetSyncedData(buffer, ref index, eventType);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Malformed data reported by {obj.name} during event type {eventType}!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (index > this.bufferIndex)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer overflow during {nameof(SyncedObject.SetSyncedData)} for {obj.name} in event type {eventType}!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var eventSize = BitConverter.ToUInt16(buffer, HeaderEventSizeIndex);
|
||||
if (index != eventSize)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Amount of data read does not match event size! Expected {eventSize}, read {index}.");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveProcessedDataFromBuffer(index);
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Processed incoming event! Total {index} bytes.");
|
||||
|
||||
retriesWithoutSuccess = 0; // We had success!
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Buffer
|
||||
private void ClearBuffer()
|
||||
{
|
||||
buffer = new byte[BufferMaxSizeBytes];
|
||||
bufferIndex = 0;
|
||||
}
|
||||
|
||||
private void RemoveProcessedDataFromBuffer(int amountProcessed)
|
||||
{
|
||||
var oldBuffer = buffer;
|
||||
bufferIndex -= amountProcessed;
|
||||
buffer = new byte[BufferMaxSizeBytes];
|
||||
Array.Copy(oldBuffer, amountProcessed, buffer, 0, bufferIndex);
|
||||
}
|
||||
|
||||
private bool IncreaseBufferSize(int newSize)
|
||||
{
|
||||
if (newSize < buffer.Length)
|
||||
{
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Cannot decrease the size of the buffer!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (newSize > BufferMaxSizeBytes)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var oldBuffer = buffer;
|
||||
buffer = new byte[newSize];
|
||||
oldBuffer.CopyTo(buffer, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool EnsureSpaceToStoreEvent(int eventSize)
|
||||
{
|
||||
if (bufferIndex + eventSize <= buffer.Length)
|
||||
{
|
||||
return true; // Enough space!
|
||||
}
|
||||
|
||||
var newBufferSize = ((bufferIndex + eventSize) / BufferIncrementSizeBytes + 1) * BufferIncrementSizeBytes;
|
||||
|
||||
var success = IncreaseBufferSize(newBufferSize);
|
||||
if (success)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bufferIndex == 0)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer is not large enough to store event!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store event!");
|
||||
}
|
||||
|
||||
HandleError(); // We can store event now that we cleared the buffer.
|
||||
return false;
|
||||
}
|
||||
|
||||
private void AppendEventToBuffer(int index, int size)
|
||||
{
|
||||
if (!EnsureSpaceToStoreEvent(size))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Array.Copy(networkedData, index, buffer, this.bufferIndex, size);
|
||||
this.bufferIndex += size;
|
||||
|
||||
UpdateNextEventTime();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Time
|
||||
private void ProgressSyncedTime(float newTime)
|
||||
{
|
||||
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) updating SyncedTime from {SyncedTime} to {newTime}");
|
||||
Dt = newTime - SyncedTime;
|
||||
SyncedTime = newTime;
|
||||
}
|
||||
|
||||
private void SyncToTimestamp(uint timestamp)
|
||||
{
|
||||
var oldOffset = offsetTime;
|
||||
var timeToSyncTo = timestamp / (float)TimestampMultiplier - Delay;
|
||||
offsetTime = Time.fixedTime - timeToSyncTo;
|
||||
|
||||
var delta = offsetTime - oldOffset;
|
||||
internalTime = internalTime - delta;
|
||||
SyncedTime = SyncedTime - delta;
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to timestamp {timestamp}, current time is {Time.fixedTime}, timeToSyncTo is {timeToSyncTo}, offsetTime is now {offsetTime}, internalTime is now {internalTime}, SyncedTime is now {SyncedTime}");
|
||||
}
|
||||
|
||||
private void UpdateNextEventTime()
|
||||
{
|
||||
if (bufferIndex == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var nextEventTime = TimestampToTime(BitConverter.ToUInt32(buffer, HeaderTimestampIndex));
|
||||
if (nextEventTime >= this.nextEventTime)
|
||||
{
|
||||
this.nextEventTime = nextEventTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event is earlier than previous event!");
|
||||
HandleError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static uint TimeToTimestamp(float time)
|
||||
{
|
||||
return (uint)((time * TimestampMultiplier) + TimestampZeroValue);
|
||||
}
|
||||
|
||||
public static float TimestampToTime(uint timeStamp)
|
||||
{
|
||||
return (timeStamp - (long)TimestampZeroValue) / (float)TimestampMultiplier; // Use a long here to prevent an underflow
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VRC events
|
||||
public override void OnOwnershipTransferred(VRCPlayerApi newOwner)
|
||||
{
|
||||
SetOwner(newOwner == Networking.LocalPlayer);
|
||||
@@ -451,8 +596,8 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
if (isOwner)
|
||||
{
|
||||
networkedData = new byte[index];
|
||||
Array.Copy(buffer, networkedData, index);
|
||||
networkedData = new byte[bufferIndex];
|
||||
Array.Copy(buffer, networkedData, bufferIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -487,30 +632,9 @@ namespace Marro.PacManUdon
|
||||
ProcessIncomingData();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void UpdateTime(long timeTicks)
|
||||
{
|
||||
CurrentTimeTicks = timeTicks;
|
||||
|
||||
foreach (var obj in syncedObjects)
|
||||
{
|
||||
obj.Dt = (timeTicks - obj.LastUpdateTicks) / (float)TimeSpan.TicksPerSecond;
|
||||
obj.LastUpdateTicks = timeTicks;
|
||||
}
|
||||
}
|
||||
|
||||
public uint GetTimestamp(long timeTicks)
|
||||
{
|
||||
return (uint)((timeTicks - startTimeTicks) / TimeSpan.TicksPerMillisecond);
|
||||
}
|
||||
|
||||
public long GetTimeTicks(uint timeStamp)
|
||||
{
|
||||
return timeStamp * TimeSpan.TicksPerMillisecond + startTimeTicks;
|
||||
}
|
||||
|
||||
public bool IsOwner => isOwner;
|
||||
|
||||
#region Utils
|
||||
public string BytesToString(byte[] bytes)
|
||||
{
|
||||
var sb = new StringBuilder("new byte[] { ");
|
||||
@@ -521,5 +645,23 @@ namespace Marro.PacManUdon
|
||||
sb.Append("}");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static void FlattenAndCopy(byte[][] data, int length, byte[] target, ref int index)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
var values = data[i];
|
||||
Array.Copy(values, 0, target, index, values.Length);
|
||||
index += values.Length;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Debug
|
||||
public void SimulateSyncToTimestamp(uint timestamp)
|
||||
{
|
||||
SyncToTimestamp(timestamp);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -75,7 +75,7 @@
|
||||
animator.SetTrigger("Reset");
|
||||
}
|
||||
|
||||
public override void FixedUpdate()
|
||||
public override void SyncedUpdate()
|
||||
{
|
||||
// gameStateManager.statusDisplay.SetDebugText(1, this.targetDirection.ToString());
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
public abstract class SyncedObject : UdonSharpBehaviour
|
||||
{
|
||||
public long LastUpdateTicks { get; set; }
|
||||
public float Dt { get; set; }
|
||||
public abstract void FixedUpdate();
|
||||
public abstract void SyncedUpdate();
|
||||
public abstract void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType);
|
||||
public abstract bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType);
|
||||
}
|
||||
|
||||
@@ -49,19 +49,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <LastUpdateTicks>k__BackingField
|
||||
Data: start
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <LastUpdateTicks>k__BackingField
|
||||
Data: start
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 3|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int64, mscorlib
|
||||
Data: UnityEngine.Transform, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
@@ -79,13 +79,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 5|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
@@ -103,25 +109,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <Dt>k__BackingField
|
||||
Data: end
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <Dt>k__BackingField
|
||||
Data: end
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 6|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Single, mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Entry: 9
|
||||
Data: 3
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 6
|
||||
Data: 3
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -133,13 +133,85 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 7|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 8|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: mode
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: mode
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 10|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: TestBallMode, Assembly-CSharp
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 11|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32, mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
@@ -160,13 +232,13 @@ MonoBehaviour:
|
||||
Data: networkManager
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 8|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: networkManager
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 9|System.RuntimeType, mscorlib
|
||||
Data: 15|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
|
||||
@@ -175,7 +247,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 10|System.RuntimeType, mscorlib
|
||||
Data: 16|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: VRC.Udon.UdonBehaviour, VRC.Udon
|
||||
@@ -193,19 +265,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: true
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 11|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 12|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
@@ -223,133 +289,25 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: start
|
||||
Data: sumOfDt
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 13|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 18|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: start
|
||||
Data: sumOfDt
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 14|System.RuntimeType, mscorlib
|
||||
Data: 19|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: UnityEngine.Transform, UnityEngine.CoreModule
|
||||
Data: System.Single, mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 14
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 16|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: end
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: end
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 14
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 14
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: true
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 1
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data: 19|UnityEngine.SerializeField, UnityEngine.CoreModule
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: amountUp
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: amountUp
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 6
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 6
|
||||
Data: 19
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -364,7 +322,55 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: amountUp
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 21|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: amountUp
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 19
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 19
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -388,22 +394,16 @@ MonoBehaviour:
|
||||
Data: loopOffset
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: loopOffset
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 23|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32, mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Entry: 9
|
||||
Data: 11
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 23
|
||||
Data: 11
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
|
||||
@@ -3,32 +3,49 @@ using Marro.PacManUdon;
|
||||
using System;
|
||||
using System.Drawing.Text;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase;
|
||||
|
||||
|
||||
enum TestBallMode
|
||||
{
|
||||
UseNetworkTime,
|
||||
UseNetworkDt,
|
||||
UseUnityDt,
|
||||
}
|
||||
|
||||
public class TestBall : SyncedObject
|
||||
{
|
||||
[SerializeField] private NetworkManager networkManager;
|
||||
[SerializeField] private Transform start;
|
||||
[SerializeField] private Transform end;
|
||||
|
||||
[SerializeField] private TestBallMode mode;
|
||||
|
||||
private NetworkManager networkManager;
|
||||
|
||||
private const int LoopTimeMs = 1000;
|
||||
private const float MaxUp = 0.7f;
|
||||
private const float UpPerPress = 0.4f;
|
||||
private const float DownPerSecond = 1;
|
||||
|
||||
private float sumOfDt;
|
||||
|
||||
private float amountUp = 0;
|
||||
private int loopOffset = 0;
|
||||
|
||||
private void Start()
|
||||
public void Initialize(NetworkManager networkManager)
|
||||
{
|
||||
networkManager.Initialize();
|
||||
this.networkManager = networkManager;
|
||||
sumOfDt = networkManager.SyncedTime;
|
||||
}
|
||||
|
||||
public override void FixedUpdate()
|
||||
public override void SyncedUpdate()
|
||||
{
|
||||
DeltaUp(-DownPerSecond * Dt);
|
||||
DeltaUp(-DownPerSecond * networkManager.Dt);
|
||||
|
||||
UpdateProgress();
|
||||
|
||||
float progress = GetProgress();
|
||||
transform.position = Vector3.Lerp(start.position, end.position, progress) + amountUp * MaxUp * Vector3.up;;
|
||||
transform.position = Vector3.Lerp(start.position, end.position, progress) + amountUp * MaxUp * Vector3.up;
|
||||
}
|
||||
|
||||
private void DeltaUp(float delta)
|
||||
@@ -38,16 +55,48 @@ public class TestBall : SyncedObject
|
||||
|
||||
private void SetProgress(float progress)
|
||||
{
|
||||
var currentTimestamp = networkManager.GetTimestamp(networkManager.CurrentTimeTicks);
|
||||
var currentTimestamp = NetworkManager.TimeToTimestamp(networkManager.SyncedTime);
|
||||
loopOffset = (int)(currentTimestamp - progress * LoopTimeMs);
|
||||
}
|
||||
|
||||
private float GetProgress()
|
||||
{
|
||||
var currentTimestamp = networkManager.GetTimestamp(networkManager.CurrentTimeTicks);
|
||||
var currentTimestamp = GetCurrentTimestamp();
|
||||
//Debug.Log($"CurrentTimeStamp for mode {mode}: {currentTimestamp}");
|
||||
return ((int)currentTimestamp - loopOffset) % LoopTimeMs / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
|
||||
}
|
||||
|
||||
private uint GetCurrentTimestamp()
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case TestBallMode.UseNetworkTime:
|
||||
return NetworkManager.TimeToTimestamp(networkManager.SyncedTime);
|
||||
case TestBallMode.UseNetworkDt:
|
||||
case TestBallMode.UseUnityDt:
|
||||
return NetworkManager.TimeToTimestamp(sumOfDt);
|
||||
default:
|
||||
Debug.LogError($"({nameof(TestBall)}) Unknown mode {mode}!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateProgress()
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case TestBallMode.UseNetworkDt:
|
||||
sumOfDt += networkManager.Dt;
|
||||
break;
|
||||
case TestBallMode.UseUnityDt:
|
||||
if (!networkManager.IsEventUpdate)
|
||||
{
|
||||
sumOfDt += Time.fixedDeltaTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpButtonPressed()
|
||||
{
|
||||
DeltaUp(UpPerPress);
|
||||
@@ -55,12 +104,6 @@ public class TestBall : SyncedObject
|
||||
networkManager.SendEvent((NetworkEventType)1);
|
||||
}
|
||||
|
||||
public void SyncButtonPressed()
|
||||
{
|
||||
networkManager.SendEvent((NetworkEventType)0);
|
||||
Debug.Log($"({nameof(TestBall)}) Sync button pressed, synced at progress {GetProgress()} and amountUp {amountUp}.");
|
||||
}
|
||||
|
||||
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType == 0)
|
||||
|
||||
52
Assets/Test stuff/TestBallManager.asset
Normal file
52
Assets/Test stuff/TestBallManager.asset
Normal file
@@ -0,0 +1,52 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: TestBallManager
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 007782662b6528e4a855cc8fb5cca273, type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
sourceCsScript: {fileID: 11500000, guid: 40fc654db4dfd4f4c9cdf45903f134a3, type: 3}
|
||||
scriptVersion: 2
|
||||
compiledVersion: 2
|
||||
behaviourSyncMode: 0
|
||||
hasInteractEvent: 0
|
||||
scriptID: 8109348476653380640
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
Prefab: {fileID: 0}
|
||||
PrefabModificationsReferencedUnityObjects: []
|
||||
PrefabModifications: []
|
||||
SerializationNodes:
|
||||
- Name: fieldDefinitions
|
||||
Entry: 7
|
||||
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
|
||||
UdonSharp.Editor]], mscorlib
|
||||
- Name: comparer
|
||||
Entry: 7
|
||||
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
|
||||
mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
8
Assets/Test stuff/TestBallManager.asset.meta
Normal file
8
Assets/Test stuff/TestBallManager.asset.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 366d931a37811ce47be572127126c17b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/Test stuff/TestBallManager.cs
Normal file
43
Assets/Test stuff/TestBallManager.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
using Marro.PacManUdon;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
|
||||
public class TestBallManager : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] TestBall[] testBalls;
|
||||
[SerializeField] NetworkManager networkManager;
|
||||
void Start()
|
||||
{
|
||||
networkManager.Initialize();
|
||||
foreach (var testBall in testBalls)
|
||||
{
|
||||
testBall.Initialize(networkManager);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpButtonPressed()
|
||||
{
|
||||
foreach (var testBall in testBalls)
|
||||
{
|
||||
testBall.UpButtonPressed();
|
||||
}
|
||||
|
||||
networkManager.SendEvent((NetworkEventType)1);
|
||||
}
|
||||
|
||||
public void SyncButtonPressed()
|
||||
{
|
||||
if (VRCPlayerApi.GetPlayerCount() == 1)
|
||||
{
|
||||
networkManager.SimulateSyncToTimestamp(NetworkManager.TimeToTimestamp(networkManager.SyncedTime - 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
networkManager.SendEvent((NetworkEventType)0);
|
||||
}
|
||||
Debug.Log($"({nameof(TestBall)}) Sync button pressed, synced at progress {GetProgress()} and amountUp {amountUp}.");
|
||||
}
|
||||
}
|
||||
11
Assets/Test stuff/TestBallManager.cs.meta
Normal file
11
Assets/Test stuff/TestBallManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40fc654db4dfd4f4c9cdf45903f134a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user