diff --git a/Assets/UnityWebSocket/Demo/MemoryDemoScene.unity b/Assets/UnityWebSocket/Demo/MemoryDemoScene.unity new file mode 100644 index 00000000..338ebd12 --- /dev/null +++ b/Assets/UnityWebSocket/Demo/MemoryDemoScene.unity @@ -0,0 +1,256 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 4890085278179872738, guid: 1a8138b2e86074b858b2ed50b14aff07, + type: 2} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &516737225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 516737226} + - component: {fileID: 516737227} + m_Layer: 0 + m_Name: Main + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &516737226 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 516737225} + 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: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &516737227 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 516737225} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ea8b19add681646fdaded33090ff1994, type: 3} + m_Name: + m_EditorClassIdentifier: + address: wss://echo.websocket.events + TestOffset: 1 +--- !u!1 &902376145 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 902376148} + - component: {fileID: 902376147} + - component: {fileID: 902376146} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &902376146 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902376145} + m_Enabled: 1 +--- !u!20 &902376147 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902376145} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.3301887, g: 0.3301887, b: 0.3301887, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &902376148 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902376145} + 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: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/UnityWebSocket/Demo/MemoryDemoScene.unity.meta b/Assets/UnityWebSocket/Demo/MemoryDemoScene.unity.meta new file mode 100644 index 00000000..a1f8fe73 --- /dev/null +++ b/Assets/UnityWebSocket/Demo/MemoryDemoScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ec5fbd8fa14a64c1f9f024cde0fbc85a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Demo/PerformaceTest.unity b/Assets/UnityWebSocket/Demo/PerformaceTest.unity new file mode 100644 index 00000000..a7a27657 --- /dev/null +++ b/Assets/UnityWebSocket/Demo/PerformaceTest.unity @@ -0,0 +1,643 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.3708985, g: 0.3783704, b: 0.35722548, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 4890085278179872738, guid: de35030f1fe336f4b8b227796a4f4ac0, + type: 2} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &473209101 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 473209102} + - component: {fileID: 473209104} + - component: {fileID: 473209103} + m_Layer: 5 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &473209102 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 473209101} + 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: 1308085638} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &473209103 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 473209101} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: TEST +--- !u!222 &473209104 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 473209101} + m_CullTransparentMesh: 1 +--- !u!1 &516737225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 516737226} + - component: {fileID: 516737228} + m_Layer: 0 + m_Name: Main + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &516737226 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 516737225} + serializedVersion: 2 + 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: 1866773715} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &516737228 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 516737225} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a323646c8d4e9448a6f7c659e5f3539, type: 3} + m_Name: + m_EditorClassIdentifier: + address: wss://echo.websocket.events + sendText: Hello UnityWebSocket! + btn: {fileID: 1308085639} +--- !u!1 &775641376 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 775641379} + - component: {fileID: 775641378} + - component: {fileID: 775641377} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &775641377 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 775641376} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &775641378 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 775641376} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &775641379 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 775641376} + serializedVersion: 2 + 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: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &902376145 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 902376148} + - component: {fileID: 902376147} + - component: {fileID: 902376146} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &902376146 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902376145} + m_Enabled: 1 +--- !u!20 &902376147 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902376145} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.3301887, g: 0.3301887, b: 0.3301887, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &902376148 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 902376145} + serializedVersion: 2 + 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: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1308085637 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1308085638} + - component: {fileID: 1308085641} + - component: {fileID: 1308085640} + - component: {fileID: 1308085639} + m_Layer: 5 + m_Name: Case1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1308085638 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1308085637} + 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: 473209102} + m_Father: {fileID: 1866773715} + 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: 0, y: 0} + m_SizeDelta: {x: 160, y: 60} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1308085639 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1308085637} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1308085640} + m_OnClick: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &1308085640 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1308085637} + 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: 0.4056604, g: 0.4056604, b: 0.4056604, 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: 10905, guid: 0000000000000000f000000000000000, type: 0} + 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!222 &1308085641 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1308085637} + m_CullTransparentMesh: 1 +--- !u!1 &1866773714 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1866773715} + - component: {fileID: 1866773718} + - component: {fileID: 1866773717} + - component: {fileID: 1866773716} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1866773715 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1866773714} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1308085638} + m_Father: {fileID: 516737226} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!114 &1866773716 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1866773714} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1866773717 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1866773714} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &1866773718 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1866773714} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 0 + m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 902376148} + - {fileID: 516737226} + - {fileID: 775641379} diff --git a/Assets/UnityWebSocket/Demo/PerformaceTest.unity.meta b/Assets/UnityWebSocket/Demo/PerformaceTest.unity.meta new file mode 100644 index 00000000..c21840f1 --- /dev/null +++ b/Assets/UnityWebSocket/Demo/PerformaceTest.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a50f5f77b5b30b1479ae3fd2d7cd89a7 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Demo/PerformanceTest.cs b/Assets/UnityWebSocket/Demo/PerformanceTest.cs new file mode 100644 index 00000000..7414ddb3 --- /dev/null +++ b/Assets/UnityWebSocket/Demo/PerformanceTest.cs @@ -0,0 +1,76 @@ +using System.Collections; +using System.Net.Sockets; +using UnityEngine; +using UnityEngine.UI; + +namespace UnityWebSocket.Demo +{ + public class PerformanceTest : MonoBehaviour + { + public string address = "wss://echo.websocket.events"; + public string sendText = "Hello UnityWebSocket!"; + public Button btn; + + private WebSocket socket; + + private void Awake() + { + btn.onClick.AddListener(ButtonClick); + } + + public void ButtonClick() + { + StartCoroutine(TestCase1()); + } + + private void AddLog(string str) + { + Debug.Log(str); + } + + private void Socket_OnOpen(object sender, OpenEventArgs e) + { + AddLog(string.Format("Connected: {0}", address)); + } + + private void Socket_OnMessage(object sender, PooledBuffer e) + { + if (e.IsBinary) + { + AddLog(string.Format("Receive Bytes ({1}): {0}", e.Data, e.Bytes.Length)); + } + else if (e.IsText) + { + AddLog(string.Format("Receive: {0}", e.Data)); + } + } + + private void Socket_OnClose(object sender, CloseEventArgs e) + { + AddLog(string.Format("Closed: StatusCode: {0}, Reason: {1}", e.StatusCode, e.Reason)); + } + + private void Socket_OnError(object sender, ErrorEventArgs e) + { + AddLog(string.Format("Error: {0}", e.Message)); + } + + static WaitForSeconds wait5000 = new WaitForSeconds(5); + static WaitForSeconds wait1000 = new WaitForSeconds(1); + static WaitForSeconds wait100 = new WaitForSeconds(0.1f); + static WaitForSeconds wait10 = new WaitForSeconds(0.01f); + private IEnumerator TestCase1() + { + socket = new WebSocket(address); + socket.ConnectAsync(); + yield return wait5000; + byte[] data = System.Text.Encoding.UTF8.GetBytes(sendText); + for (int i = 0; i < 100; i++) + { + socket.SendAsync(data); + yield return wait100; + } + socket.CloseAsync(); + } + } +} diff --git a/Assets/UnityWebSocket/Demo/PerformanceTest.cs.meta b/Assets/UnityWebSocket/Demo/PerformanceTest.cs.meta new file mode 100644 index 00000000..6c03b4e8 --- /dev/null +++ b/Assets/UnityWebSocket/Demo/PerformanceTest.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7a323646c8d4e9448a6f7c659e5f3539 +timeCreated: 1466599118 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs b/Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs index 353a6cfe..0a9250bd 100644 --- a/Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs +++ b/Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs @@ -151,11 +151,11 @@ private void Socket_OnOpen(object sender, OpenEventArgs e) AddLog(string.Format("Connected: {0}", address)); } - private void Socket_OnMessage(object sender, MessageEventArgs e) + private void Socket_OnMessage(object sender, PooledBuffer e) { if (e.IsBinary) { - AddLog(string.Format("Receive Bytes ({1}): {0}", e.Data, e.RawData.Length)); + AddLog(string.Format("Receive Bytes ({1}): {0}", e.Data, e.Length)); } else if (e.IsText) { diff --git a/Assets/UnityWebSocket/Demo/UnityWebSocketMemoryDemo.cs b/Assets/UnityWebSocket/Demo/UnityWebSocketMemoryDemo.cs new file mode 100644 index 00000000..71899fcf --- /dev/null +++ b/Assets/UnityWebSocket/Demo/UnityWebSocketMemoryDemo.cs @@ -0,0 +1,141 @@ +// #define UNITY_WEBSOCKET_DEMO_LOG + +using System.Collections; +using UnityEngine; +using System.Linq; + +namespace UnityWebSocket.Demo +{ + public class UnityWebSocketMemoryDemo : MonoBehaviour + { + public string address = "wss://echo.websocket.events"; + + private IWebSocket socket; + public bool TestOffset; + private int receiveCount = 0; + + private void Start() + { + StartCoroutine(RoutineTest()); + } + + static readonly byte[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray().Select(c => (byte)c).ToArray(); + + byte[] buffs = new byte[1]; + + private byte[] RandomBuffer_offset(int length) + { + if (buffs.Length != length) + buffs = new byte[length]; + for (int i = 0; i < length - 1; i++) + { + buffs[i] = chars[Random.Range(0, chars.Length)]; + } + + return buffs; + } + private PooledBuffer RandomBuffer(int length) + { + PooledBuffer buffer = PooledBuffer.Create(Opcode.Binary); + for (int i = 0; i < length - 1; i++) + { + buffer.Write(chars[Random.Range(0, chars.Length)], i); + } + buffer.Write((byte)0, length - 1); + + return buffer; + } + + private IEnumerator RoutineTest() + { + while (true) + { + if (socket == null) + { + socket = new WebSocket(address); + socket.OnOpen += Socket_OnOpen; + socket.OnMessage += Socket_OnMessage; + socket.OnClose += Socket_OnClose; + socket.OnError += Socket_OnError; + socket.ConnectAsync(); + } + + socket.ConnectAsync(); + //yield return new WaitForSeconds(2); + while (socket.ReadyState != WebSocketState.Open) + { + yield return null; + } + + var delay = new WaitForSeconds(1f); + var sendCount = 0; + while (socket.ReadyState == WebSocketState.Open) + { + + if (TestOffset) + { + var len = Random.Range(1, 20); + var message = RandomBuffer_offset(len); + Debug.Log(string.Format("Send: {0}", System.Text.Encoding.UTF8.GetString(message, 0, len))); + socket.SendAsync(message, 0, len); + + } + else + { + // buffer with random length to detect reuse + var message = RandomBuffer(Random.Range(1, 512)); + + // buffer with 32 bytes to detect reuse + // var message = RandomBuffer(32); + Debug.Log(string.Format("Send: {0}", message.Data)); + + + socket.SendAsync(message); + + } + + sendCount += 1; + yield return delay; + } + } + } + + + + + + private void Socket_OnOpen(object sender, OpenEventArgs e) + { + Debug.Log(string.Format("Connected: {0}", address)); + } + + private void Socket_OnMessage(object sender, PooledBuffer e) + { +#if !UNITY_WEBSOCKET_DEMO_LOG + Debug.Log(string.Format("Recv: {0}", e.Data)); +#endif + + e.Dispose(); + + receiveCount += 1; + } + + private void Socket_OnClose(object sender, CloseEventArgs e) + { + Debug.Log(string.Format("Closed: StatusCode: {0}, Reason: {1}", e.StatusCode, e.Reason)); + } + + private void Socket_OnError(object sender, ErrorEventArgs e) + { + Debug.Log(string.Format("Error: {0}", e.Message)); + } + + private void OnApplicationQuit() + { + if (socket != null && socket.ReadyState != WebSocketState.Closed) + { + socket.CloseAsync(); + } + } + } +} diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs.meta b/Assets/UnityWebSocket/Demo/UnityWebSocketMemoryDemo.cs.meta similarity index 83% rename from Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs.meta rename to Assets/UnityWebSocket/Demo/UnityWebSocketMemoryDemo.cs.meta index 1c3a7d13..c0e7b156 100644 --- a/Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs.meta +++ b/Assets/UnityWebSocket/Demo/UnityWebSocketMemoryDemo.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b44eda173b4924081bab76ae9d1b0a9c +guid: ea8b19add681646fdaded33090ff1994 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib b/Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib index c7477a98..5164d922 100644 --- a/Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib +++ b/Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib @@ -32,8 +32,7 @@ var WebSocketLibrary = * Support Unity 6000 * */ - WebSocketSetSupport6000: function() - { + WebSocketSetSupport6000: function () { webSocketManager.support6000 = true; }, @@ -42,8 +41,7 @@ var WebSocketLibrary = * * @param callback Reference to C# static function */ - WebSocketSetOnOpen: function(callback) - { + WebSocketSetOnOpen: function (callback) { webSocketManager.onOpen = callback; }, @@ -52,8 +50,7 @@ var WebSocketLibrary = * * @param callback Reference to C# static function */ - WebSocketSetOnMessage: function(callback) - { + WebSocketSetOnMessage: function (callback) { webSocketManager.onMessage = callback; }, @@ -62,8 +59,7 @@ var WebSocketLibrary = * * @param callback Reference to C# static function */ - WebSocketSetOnMessageStr: function(callback) - { + WebSocketSetOnMessageStr: function (callback) { webSocketManager.onMessageStr = callback; }, @@ -72,8 +68,7 @@ var WebSocketLibrary = * * @param callback Reference to C# static function */ - WebSocketSetOnError: function(callback) - { + WebSocketSetOnError: function (callback) { webSocketManager.onError = callback; }, @@ -82,8 +77,7 @@ var WebSocketLibrary = * * @param callback Reference to C# static function */ - WebSocketSetOnClose: function(callback) - { + WebSocketSetOnClose: function (callback) { webSocketManager.onClose = callback; }, @@ -92,8 +86,7 @@ var WebSocketLibrary = * * @param url Server URL */ - WebSocketAllocate: function(urlPtr) - { + WebSocketAllocate: function (urlPtr) { var url = UTF8ToString(urlPtr); var id = ++webSocketManager.lastId; webSocketManager.instances[id] = { @@ -110,15 +103,14 @@ var WebSocketLibrary = * @param instanceId Instance ID * @param protocol Sub Protocol */ - WebSocketAddSubProtocol: function(instanceId, protocolPtr) - { + WebSocketAddSubProtocol: function (instanceId, protocolPtr) { var instance = webSocketManager.instances[instanceId]; if (!instance) return -1; var protocol = UTF8ToString(protocolPtr); - - if (instance.subProtocols == null) - instance.subProtocols = []; + + if (instance.subProtocols == null) + instance.subProtocols = []; instance.subProtocols.push(protocol); @@ -133,8 +125,7 @@ var WebSocketLibrary = * * @param instanceId Instance ID */ - WebSocketFree: function(instanceId) - { + WebSocketFree: function (instanceId) { var instance = webSocketManager.instances[instanceId]; if (!instance) return 0; @@ -147,14 +138,13 @@ var WebSocketLibrary = return 0; }, - + /** * Connect WebSocket to the server * * @param instanceId Instance ID */ - WebSocketConnect: function(instanceId) - { + WebSocketConnect: function (instanceId) { var instance = webSocketManager.instances[instanceId]; if (!instance) return -1; if (instance.ws !== null) return -2; @@ -163,138 +153,87 @@ var WebSocketLibrary = instance.ws = new WebSocket(instance.url, instance.subProtocols); else instance.ws = new WebSocket(instance.url); - - instance.ws.onopen = function() - { - if (webSocketManager.support6000) - { - {{{ makeDynCall('vi', 'webSocketManager.onOpen') }}}(instanceId); + // Set binaryType to arraybuffer to prevent blob message + instance.ws.binaryType = 'arraybuffer'; + instance.ws.onopen = function () { + if (webSocketManager.support6000) { + { { { makeDynCall('vi', 'webSocketManager.onOpen') } } } (instanceId); } - else - { + else { Module.dynCall_vi(webSocketManager.onOpen, instanceId); } }; - instance.ws.onmessage = function(ev) - { - if (ev.data instanceof ArrayBuffer) - { + instance.ws.onmessage = function (ev) { + if (ev.data instanceof ArrayBuffer) { var array = new Uint8Array(ev.data); var buffer = _malloc(array.length); writeArrayToMemory(array, buffer); - try - { - if (webSocketManager.support6000) - { - {{{ makeDynCall('viii', 'webSocketManager.onMessage') }}}(instanceId, buffer, array.length); + try { + if (webSocketManager.support6000) { + { { { makeDynCall('viii', 'webSocketManager.onMessage') } } } (instanceId, buffer, array.length); } - else - { + else { Module.dynCall_viii(webSocketManager.onMessage, instanceId, buffer, array.length); } } - finally - { + finally { _free(buffer); } } - else if (typeof ev.data == 'string') - { + else if (typeof ev.data == 'string') { var length = lengthBytesUTF8(ev.data) + 1; var buffer = _malloc(length); stringToUTF8(ev.data, buffer, length); - try - { - if (webSocketManager.support6000) - { - {{{ makeDynCall('vii', 'webSocketManager.onMessageStr') }}}(instanceId, buffer); + try { + if (webSocketManager.support6000) { + { { { makeDynCall('vii', 'webSocketManager.onMessageStr') } } } (instanceId, buffer, length); } - else - { - Module.dynCall_vii(webSocketManager.onMessageStr, instanceId, buffer); + else { + Module.dynCall_vii(webSocketManager.onMessageStr, instanceId, buffer, length); } } - finally - { + finally { _free(buffer); } } - else if (typeof Blob !== 'undefined' && ev.data instanceof Blob) - { - var reader = new FileReader(); - reader.onload = function() - { - var array = new Uint8Array(reader.result); - var buffer = _malloc(array.length); - writeArrayToMemory(array, buffer); - try - { - if (webSocketManager.support6000) - { - {{{ makeDynCall('viii', 'webSocketManager.onMessage') }}}(instanceId, buffer, array.length); - } - else - { - Module.dynCall_viii(webSocketManager.onMessage, instanceId, buffer, array.length); - } - } - finally - { - reader = null; - _free(buffer); - } - }; - reader.readAsArrayBuffer(ev.data); - } - else - { + else { console.log("[JSLIB WebSocket] not support message type: ", (typeof ev.data)); } }; - instance.ws.onerror = function(ev) - { + instance.ws.onerror = function (ev) { var msg = "WebSocket error."; var length = lengthBytesUTF8(msg) + 1; var buffer = _malloc(length); stringToUTF8(msg, buffer, length); - try - { - if (webSocketManager.support6000) - { - {{{ makeDynCall('vii', 'webSocketManager.onError') }}}(instanceId, buffer); + try { + if (webSocketManager.support6000) { + { { { makeDynCall('vii', 'webSocketManager.onError') } } } (instanceId, buffer); } - else - { + else { Module.dynCall_vii(webSocketManager.onError, instanceId, buffer); } } - finally - { + finally { _free(buffer); } }; - instance.ws.onclose = function(ev) - { + instance.ws.onclose = function (ev) { var msg = ev.reason; var length = lengthBytesUTF8(msg) + 1; var buffer = _malloc(length); stringToUTF8(msg, buffer, length); - try - { - if (webSocketManager.support6000) - { - {{{ makeDynCall('viii', 'webSocketManager.onClose') }}}(instanceId, ev.code, buffer); + try { + if (webSocketManager.support6000) { + { { { makeDynCall('viii', 'webSocketManager.onClose') } } } (instanceId, ev.code, buffer); } - else - { + else { Module.dynCall_viii(webSocketManager.onClose, instanceId, ev.code, buffer); } } - finally - { + finally { _free(buffer); } instance.ws = null; @@ -310,21 +249,18 @@ var WebSocketLibrary = * @param code Close status code * @param reasonPtr Pointer to reason string */ - WebSocketClose: function(instanceId, code, reasonPtr) - { + WebSocketClose: function (instanceId, code, reasonPtr) { var instance = webSocketManager.instances[instanceId]; if (!instance) return -1; if (instance.ws === null) return -3; if (instance.ws.readyState === 2) return -4; if (instance.ws.readyState === 3) return -5; - var reason = ( reasonPtr ? UTF8ToString(reasonPtr) : undefined ); - try - { + var reason = (reasonPtr ? UTF8ToString(reasonPtr) : undefined); + try { instance.ws.close(code, reason); } - catch (err) - { + catch (err) { return -7; } @@ -338,17 +274,16 @@ var WebSocketLibrary = * @param bufferPtr Pointer to the message buffer * @param length Length of the message in the buffer */ - WebSocketSend: function(instanceId, bufferPtr, length) - { + WebSocketSend: function (instanceId, bufferPtr,offset, length) { var instance = webSocketManager.instances[instanceId]; if (!instance) return -1; if (instance.ws === null) return -3; if (instance.ws.readyState !== 1) return -6; if (typeof HEAPU8 !== 'undefined') - instance.ws.send(HEAPU8.buffer.slice(bufferPtr, bufferPtr + length)); + instance.ws.send(HEAPU8.buffer.slice(bufferPtr + offset, bufferPtr + length)); else if (typeof buffer !== 'undefined') - instance.ws.send(buffer.slice(bufferPtr, bufferPtr + length)); + instance.ws.send(buffer.slice(bufferPtr + offset, bufferPtr + length)); else return -8; // not support buffer slice @@ -361,8 +296,7 @@ var WebSocketLibrary = * @param instanceId Instance ID * @param stringPtr Pointer to the message string */ - WebSocketSendStr: function(instanceId, stringPtr) - { + WebSocketSendStr: function (instanceId, stringPtr) { var instance = webSocketManager.instances[instanceId]; if (!instance) return -1; if (instance.ws === null) return -3; @@ -378,12 +312,11 @@ var WebSocketLibrary = * * @param instanceId Instance ID */ - WebSocketGetState: function(instanceId) - { + WebSocketGetState: function (instanceId) { var instance = webSocketManager.instances[instanceId]; if (!instance) return -1; if (instance.ws === null) return 3; // socket null as closed - + return instance.ws.readyState; } }; diff --git a/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_FORCE_WEBGL_IMPL_ENABLE.cs b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_FORCE_WEBGL_IMPL_ENABLE.cs new file mode 100644 index 00000000..50556879 --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_FORCE_WEBGL_IMPL_ENABLE.cs @@ -0,0 +1,113 @@ +#if UNITY_EDITOR +using System.Collections.Generic; +using System.Text; +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +using UnityEngine; + +namespace UnityWebSocket +{ + // This class is used to force enable the WebGL implementation + // You can enable it by menu "Tools/UnityWebSocket/FORCE_WEBGL_IMPL_ENABLE" + // If you enable it, the WebGL implementation will be used even if the platform is not WebGL + // You can write and compile the code in the editor, but it will not work in the build + // And it will show an error message when you build the project + public class DefineSymbol_FORCE_WEBGL_IMPL_ENABLE : IPreprocessBuildWithReport + { + public const string SYMBOL_NAME = "FORCE_WEBGL_IMPL_ENABLE"; + + public const string MENU_TITLE = "Tools/UnityWebSocket/Debug/" + SYMBOL_NAME; + + public int callbackOrder => -1; + public void OnPreprocessBuild(BuildReport report) + { + if (SYMBOL_IS_ENABLE) + { + SYMBOL_IS_ENABLE = false; + throw new BuildFailedException( + $"The define symbol '{SYMBOL_NAME}' is enabled, It is only used for editor. " + + "You don't need to manually turn on this setting, it will automatically switch when switching platforms."); + } + } + + + [MenuItem(MENU_TITLE, false, 1024)] + static void DefineSymbolCheckMenu() + { + SYMBOL_IS_ENABLE = !SYMBOL_IS_ENABLE; + Menu.SetChecked(MENU_TITLE, SYMBOL_IS_ENABLE); + } + + // The menu won't be gray out, we use this validate method for update check state + [MenuItem(MENU_TITLE, true)] + static bool DefineSymbolMenuValidate() + { + Menu.SetChecked(MENU_TITLE, SYMBOL_IS_ENABLE); + return true; + } + + static bool SYMBOL_IS_ENABLE + { + get + { + var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); + var sdsList = DefineSymbols_GetStat(buildTargetGroup); + return sdsList.Contains(SYMBOL_NAME); + } + + set + { + var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); + var sdsList = DefineSymbols_GetStat(buildTargetGroup); + if (value) + { + if (!sdsList.Contains(SYMBOL_NAME)) + sdsList.Add(SYMBOL_NAME); + } + else + { + if (sdsList.Contains(SYMBOL_NAME)) + sdsList.Remove(SYMBOL_NAME); + } + DefineSymbols_ApplyChanges(buildTargetGroup, sdsList); + } + } + + private static List DefineSymbols_GetStat(BuildTargetGroup buildTargetGroup) + { + var sds = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); + + List sdsList; + if (string.IsNullOrWhiteSpace(sds)) + sdsList = new List(); + else + sdsList = new List(sds.Split(';')); + + return sdsList; + } + + private static void DefineSymbols_ApplyChanges(BuildTargetGroup buildTargetGroup, List sdsList) + { + if (sdsList.Count > 0) + { + StringBuilder sb = new StringBuilder(); + sb.Append(sdsList[0]); + for (int i = 1; i < sdsList.Count; i++) + { + if (!string.IsNullOrWhiteSpace(sdsList[i])) + { + sb.Append(';'); + sb.Append(sdsList[i]); + } + } + PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, sb.ToString()); + } + else + { + PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, ""); + } + } + } +} +#endif \ No newline at end of file diff --git a/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_FORCE_WEBGL_IMPL_ENABLE.cs.meta b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_FORCE_WEBGL_IMPL_ENABLE.cs.meta new file mode 100644 index 00000000..c7eaa017 --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_FORCE_WEBGL_IMPL_ENABLE.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1bca20982ff0e4d98babb3d546ccfaae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_UNITY_WEB_SOCKET_LOG.cs b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_UNITY_WEB_SOCKET_LOG.cs new file mode 100644 index 00000000..b9be1aab --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_UNITY_WEB_SOCKET_LOG.cs @@ -0,0 +1,95 @@ +#if UNITY_EDITOR +using System.Collections.Generic; +using System.Text; +using UnityEditor; +using UnityEditor.Build; +using UnityEditor.Build.Reporting; +using UnityEngine; + +namespace UnityWebSocket +{ + public class DefineSymbol_UNITY_WEB_SOCKET_LOG + { + public const string SYMBOL_NAME = "UNITY_WEB_SOCKET_LOG"; + + public const string MENU_TITLE = "Tools/UnityWebSocket/Debug/" + SYMBOL_NAME; + + [MenuItem(MENU_TITLE, false, 1024)] + static void DefineSymbolCheckMenu() + { + SYMBOL_IS_ENABLE = !SYMBOL_IS_ENABLE; + Menu.SetChecked(MENU_TITLE, SYMBOL_IS_ENABLE); + } + + // The menu won't be gray out, we use this validate method for update check state + [MenuItem(MENU_TITLE, true)] + static bool DefineSymbolMenuValidate() + { + Menu.SetChecked(MENU_TITLE, SYMBOL_IS_ENABLE); + return true; + } + + static bool SYMBOL_IS_ENABLE + { + get + { + var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); + var sdsList = DefineSymbols_GetStat(buildTargetGroup); + return sdsList.Contains(SYMBOL_NAME); + } + + set + { + var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); + var sdsList = DefineSymbols_GetStat(buildTargetGroup); + if (value) + { + if (!sdsList.Contains(SYMBOL_NAME)) + sdsList.Add(SYMBOL_NAME); + } + else + { + if (sdsList.Contains(SYMBOL_NAME)) + sdsList.Remove(SYMBOL_NAME); + } + DefineSymbols_ApplyChanges(buildTargetGroup, sdsList); + } + } + + private static List DefineSymbols_GetStat(BuildTargetGroup buildTargetGroup) + { + var sds = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); + + List sdsList; + if (string.IsNullOrWhiteSpace(sds)) + sdsList = new List(); + else + sdsList = new List(sds.Split(';')); + + return sdsList; + } + + private static void DefineSymbols_ApplyChanges(BuildTargetGroup buildTargetGroup, List sdsList) + { + if (sdsList.Count > 0) + { + StringBuilder sb = new StringBuilder(); + sb.Append(sdsList[0]); + for (int i = 1; i < sdsList.Count; i++) + { + if (!string.IsNullOrWhiteSpace(sdsList[i])) + { + sb.Append(';'); + sb.Append(sdsList[i]); + } + } + PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, sb.ToString()); + } + else + { + PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, ""); + } + } + } +} +#endif \ No newline at end of file diff --git a/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_UNITY_WEB_SOCKET_LOG.cs.meta b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_UNITY_WEB_SOCKET_LOG.cs.meta new file mode 100644 index 00000000..06e411d6 --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Editor/DefineSymbol_UNITY_WEB_SOCKET_LOG.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df28897521164498aa666e6f5e2a5cce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Scripts/Editor/SettingsWindow.cs b/Assets/UnityWebSocket/Scripts/Editor/SettingsWindow.cs index 116e1cfc..6848bcfa 100644 --- a/Assets/UnityWebSocket/Scripts/Editor/SettingsWindow.cs +++ b/Assets/UnityWebSocket/Scripts/Editor/SettingsWindow.cs @@ -9,7 +9,7 @@ namespace UnityWebSocket.Editor internal class SettingsWindow : EditorWindow { static SettingsWindow window = null; - [MenuItem("Tools/UnityWebSocket", priority = 100)] + [MenuItem("Tools/UnityWebSocket/Settings", priority = 100)] internal static void Open() { if (window != null) diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs b/Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs index 3e08d4b5..42a3f0e1 100644 --- a/Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs +++ b/Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs @@ -76,6 +76,7 @@ public interface IWebSocket /// is . /// void SendAsync(byte[] data); + void SendAsync(byte[] data, int offset,int length); /// /// Sends the specified data using the WebSocket connection. @@ -94,6 +95,23 @@ public interface IWebSocket /// void SendAsync(string text); + /// + /// Sends the specified data using the WebSocket connection. + /// + /// + /// A that represents the data to send. + /// + /// + /// The current state of the connection is not Open. + /// + /// + /// is . + /// + /// + /// could not be UTF-8 encoded. + /// + void SendAsync(PooledBuffer buffer); + /// /// get the address which to connect. /// @@ -138,6 +156,6 @@ public interface IWebSocket /// /// Occurs when the receives a message. /// - event EventHandler OnMessage; + event EventHandler OnMessage; } } diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs b/Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs deleted file mode 100644 index a80fbae8..00000000 --- a/Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Text; - -namespace UnityWebSocket -{ - public class MessageEventArgs : EventArgs - { - private byte[] _rawData; - private string _data; - - internal MessageEventArgs(Opcode opcode, byte[] rawData) - { - Opcode = opcode; - _rawData = rawData; - } - - internal MessageEventArgs(Opcode opcode, string data) - { - Opcode = opcode; - _data = data; - } - - /// - /// Gets the opcode for the message. - /// - /// - /// , . - /// - internal Opcode Opcode { get; private set; } - - /// - /// Gets the message data as a . - /// - /// - /// A that represents the message data if its type is - /// text and if decoding it to a string has successfully done; - /// otherwise, . - /// - public string Data - { - get - { - SetData(); - return _data; - } - } - - /// - /// Gets the message data as an array of . - /// - /// - /// An array of that represents the message data. - /// - public byte[] RawData - { - get - { - SetRawData(); - return _rawData; - } - } - - /// - /// Gets a value indicating whether the message type is binary. - /// - /// - /// true if the message type is binary; otherwise, false. - /// - public bool IsBinary - { - get - { - return Opcode == Opcode.Binary; - } - } - - /// - /// Gets a value indicating whether the message type is text. - /// - /// - /// true if the message type is text; otherwise, false. - /// - public bool IsText - { - get - { - return Opcode == Opcode.Text; - } - } - - private void SetData() - { - if (_data != null) return; - - if (RawData == null) - { - return; - } - - _data = Encoding.UTF8.GetString(RawData); - } - - private void SetRawData() - { - if (_rawData != null) return; - - if (_data == null) - { - return; - } - - _rawData = Encoding.UTF8.GetBytes(_data); - } - } -} \ No newline at end of file diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs index 3755dcf5..bf6b7571 100644 --- a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs +++ b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs @@ -1,10 +1,18 @@ -#if !NET_LEGACY && (UNITY_EDITOR || !UNITY_WEBGL) +#if NET_LEGACY +#error .NET Runtime is Legacy. +/* https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket +System.Net.WebSockets.ClientWebSocket Applies to Product Versions +.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 +.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 +.NET Standard 2.0, 2.1 +*/ +#elif !(UNITY_WEBGL && !UNITY_EDITOR) && !FORCE_WEBGL_IMPL_ENABLE + using System; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Net.WebSockets; -using System.IO; using System.Collections.Concurrent; namespace UnityWebSocket @@ -40,11 +48,11 @@ public WebSocketState ReadyState public event EventHandler OnOpen; public event EventHandler OnClose; public event EventHandler OnError; - public event EventHandler OnMessage; + public event EventHandler OnMessage; private ClientWebSocket socket; private bool isOpening => socket != null && socket.State == System.Net.WebSockets.WebSocketState.Open; - private ConcurrentQueue sendQueue = new ConcurrentQueue(); + private ConcurrentQueue sendQueue = new ConcurrentQueue(); private ConcurrentQueue eventQueue = new ConcurrentQueue(); private bool closeProcessing; private CancellationTokenSource cts = null; @@ -100,41 +108,48 @@ public void CloseAsync() closeProcessing = true; } - public void SendAsync(byte[] data) + public void SendAsync(PooledBuffer buffer) + { + if (!isOpening) return; + sendQueue.Enqueue(buffer); + } + + public void SendAsync(byte[] data, int offset, int length) { if (!isOpening) return; - var buffer = new SendBuffer(data, WebSocketMessageType.Binary); + var buffer = PooledBuffer.Create(Opcode.Binary, data, offset, length); sendQueue.Enqueue(buffer); } + public void SendAsync(byte[] data) => SendAsync(data, 0, data.Length); + public void SendAsync(string text) { if (!isOpening) return; var data = Encoding.UTF8.GetBytes(text); - var buffer = new SendBuffer(data, WebSocketMessageType.Text); + var buffer = PooledBuffer.Create(Opcode.Text, data, 0, data.Length); sendQueue.Enqueue(buffer); } + #endregion - class SendBuffer + private void CleanSendQueue() { - public byte[] data; - public WebSocketMessageType type; - public SendBuffer(byte[] data, WebSocketMessageType type) + while (sendQueue.TryDequeue(out var buffer)) { - this.data = data; - this.type = type; + buffer.Dispose(); } } - private void CleanSendQueue() - { - while (sendQueue.TryDequeue(out var _)) ; - } - private void CleanEventQueue() { - while (eventQueue.TryDequeue(out var _)) ; + while (eventQueue.TryDequeue(out var e)) + { + if (e is PooledBuffer) + { + (e as PooledBuffer).Dispose(); + } + } } private async Task ConnectTask() @@ -167,12 +182,14 @@ private async void StartSendTask() try { + PooledBuffer buffer = null; while (!closeProcessing && socket != null && cts != null && !cts.IsCancellationRequested) { - while (!closeProcessing && sendQueue.Count > 0 && sendQueue.TryDequeue(out var buffer)) + while (!closeProcessing && sendQueue.Count > 0 && sendQueue.TryDequeue(out buffer)) { - Log($"Send, type: {buffer.type}, size: {buffer.data.Length}, queue left: {sendQueue.Count}"); - await socket.SendAsync(new ArraySegment(buffer.data), buffer.type, true, cts.Token); + Log($"Send, type: {buffer.Opcode}, size: {buffer.Length}, queue left: {sendQueue.Count}"); + await socket.SendAsync(new ArraySegment(buffer.Bytes, 0, buffer.Length), buffer.Opcode == Opcode.Text ? WebSocketMessageType.Text : WebSocketMessageType.Binary, true, cts.Token); + buffer.Dispose(); } Thread.Sleep(3); } @@ -203,25 +220,32 @@ private async void StartReceiveTask() string closeReason = ""; ushort closeCode = 0; bool isClosed = false; - var segment = new ArraySegment(new byte[8192]); - var ms = new MemoryStream(); + var mem = new byte[8192]; + var segment = new ArraySegment(mem); try { + PooledBuffer buffer = null; + int index = 0; while (!isClosed && !cts.IsCancellationRequested) { - var result = await socket.ReceiveAsync(segment, cts.Token); - ms.Write(segment.Array, 0, result.Count); - if (!result.EndOfMessage) continue; - var data = ms.ToArray(); - ms.SetLength(0); + WebSocketReceiveResult result = await socket.ReceiveAsync(segment, cts.Token); + if (buffer == null) buffer = PooledBuffer.Create(); + buffer.Write(mem, 0, result.Count, index); + if (!result.EndOfMessage) + { + index += result.Count; + continue; + } + index = 0; + switch (result.MessageType) { case WebSocketMessageType.Binary: - HandleMessage(Opcode.Binary, data); + HandleMessage(Opcode.Binary, buffer); break; case WebSocketMessageType.Text: - HandleMessage(Opcode.Text, data); + HandleMessage(Opcode.Text, buffer); break; case WebSocketMessageType.Close: isClosed = true; @@ -229,6 +253,7 @@ private async void StartReceiveTask() closeReason = result.CloseStatusDescription; break; } + buffer = null; } } catch (Exception e) @@ -237,10 +262,6 @@ private async void StartReceiveTask() closeCode = (ushort)CloseStatusCode.Abnormal; closeReason = e.Message; } - finally - { - ms.Close(); - } HandleClose(closeCode, closeReason); @@ -265,10 +286,11 @@ private void HandleOpen() eventQueue.Enqueue(new OpenEventArgs()); } - private void HandleMessage(Opcode opcode, byte[] rawData) + private void HandleMessage(Opcode opcode, PooledBuffer rawData) { Log($"OnMessage, type: {opcode}, size: {rawData.Length}"); - eventQueue.Enqueue(new MessageEventArgs(opcode, rawData)); + rawData.Opcode = opcode; + eventQueue.Enqueue(rawData); } private void HandleClose(ushort code, string reason) @@ -297,9 +319,9 @@ internal void Update() { OnOpen?.Invoke(this, e as OpenEventArgs); } - else if (e is MessageEventArgs) + else if (e is PooledBuffer) { - OnMessage?.Invoke(this, e as MessageEventArgs); + OnMessage?.Invoke(this, e as PooledBuffer); } else if (e is ErrorEventArgs) { diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocketManager.cs b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocketManager.cs index e3f82bd2..08e4f76e 100644 --- a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocketManager.cs +++ b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocketManager.cs @@ -1,4 +1,13 @@ -#if !NET_LEGACY && (UNITY_EDITOR || !UNITY_WEBGL) +#if NET_LEGACY +#error .NET Runtime is Legacy. +/* https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket +System.Net.WebSockets.ClientWebSocket Applies to Product Versions +.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 +.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 +.NET Standard 2.0, 2.1 +*/ +#elif !(UNITY_WEBGL && !UNITY_EDITOR) && !FORCE_WEBGL_IMPL_ENABLE + using System.Collections.Generic; using UnityEngine; diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocket.cs b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocket.cs index e2858e9c..2fe9fa0c 100644 --- a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocket.cs +++ b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocket.cs @@ -1,4 +1,12 @@ -#if !UNITY_EDITOR && UNITY_WEBGL +#if NET_LEGACY +#error .NET Runtime is Legacy. +/* https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket +System.Net.WebSockets.ClientWebSocket Applies to Product Versions +.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 +.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 +.NET Standard 2.0, 2.1 +*/ +#elif (UNITY_WEBGL && !UNITY_EDITOR ) || FORCE_WEBGL_IMPL_ENABLE using System; namespace UnityWebSocket @@ -12,7 +20,7 @@ public class WebSocket : IWebSocket public event EventHandler OnOpen; public event EventHandler OnClose; public event EventHandler OnError; - public event EventHandler OnMessage; + public event EventHandler OnMessage; internal int instanceId = 0; @@ -82,29 +90,40 @@ public void SendAsync(string text) if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); } - public void SendAsync(byte[] data) + public void SendAsync(byte[] data, int offset, int length) { Log($"Send, type: {Opcode.Binary}, size: {data.Length}"); - int code = WebSocketManager.WebSocketSend(instanceId, data, data.Length); + int code = WebSocketManager.WebSocketSend(instanceId, data, offset, length); if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); } + public void SendAsync(byte[] data) => SendAsync(data, 0, data.Length); - internal void HandleOnOpen() + public void SendAsync(PooledBuffer buffer) { - Log("OnOpen"); - OnOpen?.Invoke(this, new OpenEventArgs()); + Log($"Send, type: {buffer.Opcode}, size: {buffer.Length}"); + int code; + if (buffer.Opcode == Opcode.Text) + { + code = WebSocketManager.WebSocketSendStr(instanceId, buffer.Data); + } + else + { + code = WebSocketManager.WebSocketSend(instanceId, buffer.Bytes, 0, buffer.Length); + } + if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); + buffer.Dispose(); } - internal void HandleOnMessage(byte[] rawData) + internal void HandleOnOpen() { - Log($"OnMessage, type: {Opcode.Binary}, size: {rawData.Length}"); - OnMessage?.Invoke(this, new MessageEventArgs(Opcode.Binary, rawData)); + Log("OnOpen"); + OnOpen?.Invoke(this, new OpenEventArgs()); } - internal void HandleOnMessageStr(string data) + internal void HandleOnMessage(PooledBuffer buffer) { - Log($"OnMessage, type: {Opcode.Text}, size: {data.Length}"); - OnMessage?.Invoke(this, new MessageEventArgs(Opcode.Text, data)); + Log($"OnMessage, type: {buffer.Opcode}, size: {buffer.Length}"); + OnMessage?.Invoke(this, buffer); } internal void HandleOnClose(ushort code, string reason) diff --git a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs index 19f288cd..03273903 100644 --- a/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs +++ b/Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs @@ -1,4 +1,12 @@ -#if !UNITY_EDITOR && UNITY_WEBGL +#if NET_LEGACY +#error .NET Runtime is Legacy. +/* https://learn.microsoft.com/en-us/dotnet/api/system.net.websockets.clientwebsocket +System.Net.WebSockets.ClientWebSocket Applies to Product Versions +.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 +.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 +.NET Standard 2.0, 2.1 +*/ +#elif (UNITY_WEBGL && !UNITY_EDITOR ) || FORCE_WEBGL_IMPL_ENABLE using System; using System.Collections.Generic; using System.Runtime.InteropServices; @@ -17,7 +25,7 @@ internal static class WebSocketManager /* Delegates */ public delegate void OnOpenCallback(int instanceId); public delegate void OnMessageCallback(int instanceId, IntPtr msgPtr, int msgSize); - public delegate void OnMessageStrCallback(int instanceId, IntPtr msgStrPtr); + public delegate void OnMessageStrCallback(int instanceId, IntPtr msgPtr, int msgSize); public delegate void OnErrorCallback(int instanceId, IntPtr errorPtr); public delegate void OnCloseCallback(int instanceId, int closeCode, IntPtr reasonPtr); @@ -29,7 +37,7 @@ internal static class WebSocketManager public static extern int WebSocketClose(int instanceId, int code, string reason); [DllImport("__Internal")] - public static extern int WebSocketSend(int instanceId, byte[] dataPtr, int dataLength); + public static extern int WebSocketSend(int instanceId, byte[] dataPtr, int offset, int dataLength); [DllImport("__Internal")] public static extern int WebSocketSendStr(int instanceId, string data); @@ -61,7 +69,7 @@ internal static class WebSocketManager [DllImport("__Internal")] public static extern void WebSocketSetOnClose(OnCloseCallback callback); - + [DllImport("__Internal")] public static extern void WebSocketSetSupport6000(); @@ -97,19 +105,20 @@ public static void DelegateOnMessageEvent(int instanceId, IntPtr msgPtr, int msg { if (sockets.TryGetValue(instanceId, out var socket)) { - var bytes = new byte[msgSize]; - Marshal.Copy(msgPtr, bytes, 0, msgSize); - socket.HandleOnMessage(bytes); + var buffer = PooledBuffer.Create(Opcode.Binary); + buffer.Write(msgPtr, 0, msgSize); + socket.HandleOnMessage(buffer); } } [MonoPInvokeCallback(typeof(OnMessageStrCallback))] - public static void DelegateOnMessageStrEvent(int instanceId, IntPtr msgStrPtr) + public static void DelegateOnMessageStrEvent(int instanceId, IntPtr msgPtr, int msgSize) { if (sockets.TryGetValue(instanceId, out var socket)) { - string msgStr = Marshal.PtrToStringAuto(msgStrPtr); - socket.HandleOnMessageStr(msgStr); + var buffer = PooledBuffer.Create(Opcode.Text); + buffer.Write(msgPtr, 0, msgSize); + socket.HandleOnMessage(buffer); } } diff --git a/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer.meta b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer.meta new file mode 100644 index 00000000..effc5f28 --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1effea9b0befb4c20a9aa243559906f5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/ByteArrayPool.cs b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/ByteArrayPool.cs new file mode 100644 index 00000000..3043ecf9 --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/ByteArrayPool.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; + +namespace UnityWebSocket +{ + public class ByteArrayPool + { + public static readonly ByteArrayPool Shared = new ByteArrayPool(); + + private static readonly string TName = typeof(ByteArrayPool).Name; + + // The pool is divided into 18 buckets, each bucket is a queue. + private readonly Queue[] m_Pool; + // The stack Max Length of each bucket. + const int kQueueSize = 32; + + #region + // Only Support Kinds Of byte[] Lengths. + const int kByteLenKindCount = 17; + const int kMinByteLen = 16; + const int kMaxByteLen = 1048576; + static readonly Dictionary ByteLenToKind = new Dictionary() + { + {16, 0}, {32, 1}, {64, 2}, {128, 3}, {256, 4}, {512, 5}, {1024, 6}, + {2048, 7}, {4096, 8}, {8192, 9}, {16384, 10}, {32768, 11}, {65536, 12}, + {131072, 13}, {262144, 14}, {524288, 15}, {1048576, 16}, + }; + #endregion + + static int GetPoolIndex(int length) + { + if (length < kMinByteLen || length > kMaxByteLen) + { + return -1; + } + + return ByteLenToKind[length]; + } + + static int CalcByteLen(int size) + { + size--; + size |= size >> 1; + size |= size >> 2; + size |= size >> 4; + size |= size >> 8; + size |= size >> 16; + size += 1; + + if (size < kMinByteLen) size = kMinByteLen; + return size; + } + + public ByteArrayPool() + { + m_Pool = new Queue[kByteLenKindCount]; + } + + /// + /// The array length is not always accurate. + /// + /// + public byte[] Get(int len) + { + if (len < 0) len = 0; + + if (len == 0) + { + return Array.Empty(); + } + + int size = CalcByteLen(len); + int poolIndex = GetPoolIndex(size); + + if (poolIndex != -1) + { + if (m_Pool[poolIndex] == null) + { + m_Pool[poolIndex] = new Queue(kQueueSize); + } + + var pool = m_Pool[poolIndex]; + + if (pool.Count > 0) + { +#if UNITY_WEB_SOCKET_LOG + UnityEngine.Debug.Log($"{TName} Get byte[{size}] Reuse"); +#endif + var array = pool.Dequeue(); + return array; + } + } + +#if UNITY_WEB_SOCKET_LOG + UnityEngine.Debug.LogWarning($"{TName} Get byte[{size}] Alloc !!!"); +#endif + var allocArr = new byte[size]; + return allocArr; + } + + /// + /// Return the array to the pool. + /// The length of the array must be greater than or equal to 8 and a power of 2. + /// + /// The length of the array must be greater than or equal to 8 and a power of 2. + public void Return(byte[] array) + { + if ((array == null) || (array.Length == 0)) + { + UnityEngine.Debug.LogWarning($"ByteArrayPool Return byte[] Null Or Empty"); + return; + } + + int poolIndex = GetPoolIndex(array.Length); + if (poolIndex == -1) + { + UnityEngine.Debug.LogWarning($"ByteArrayPool Return byte[{array.Length}] Invalid Length"); + return; + } + + if (m_Pool[poolIndex] == null) + { + m_Pool[poolIndex] = new Queue(); + } + + var pool = m_Pool[poolIndex]; + + if (pool.Count >= kQueueSize) + { + // If the pool is full, we will not return the array to the pool. + UnityEngine.Debug.LogWarning($"ByteArrayPool Return byte[{array.Length}] Too Many {pool.Count} Max {kQueueSize}"); + array = null; + } + else + { +#if UNITY_WEB_SOCKET_LOG + UnityEngine.Debug.Log($"{TName} Return byte[{array.Length}] Enqueue {pool.Count + 1}"); +#endif + pool.Enqueue(array); + } + } + + /// + /// Return the array to the pool and set array reference to null. + /// The length of the array must be greater than or equal to 8 and a power of 2. + /// + /// The length of the array must be greater than or equal to 8 and a power of 2. + public void Return(ref byte[] array) + { + Return(array); + array = null; + } + + public void Cleanup() + { + // Release instances from each buckets. + for (int i = 0; i < m_Pool.Length; i++) + { + var bucket = m_Pool[i]; + bucket.Clear(); + } + } + } +} \ No newline at end of file diff --git a/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/ByteArrayPool.cs.meta b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/ByteArrayPool.cs.meta new file mode 100644 index 00000000..85670cda --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/ByteArrayPool.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ca60603f351e34b9dba16f905f2224cf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/PooledBuffer.cs b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/PooledBuffer.cs new file mode 100644 index 00000000..32ecd09b --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/PooledBuffer.cs @@ -0,0 +1,165 @@ +using System.IO; +using System; +using System.Collections.Generic; + +namespace UnityWebSocket +{ + public class PooledBuffer : EventArgs, IDisposable + { + public Opcode Opcode { get; internal set; } + public bool IsBinary => Opcode == Opcode.Binary; + public bool IsText => Opcode == Opcode.Text; + + private bool m_Disposed = false; + private byte[] m_bytes; + private int m_Count; + + public int Length => m_Count; + public byte[] Bytes => m_bytes; + public int Capacity => m_bytes.Length; + + public string Data + { + get + { + if (m_bytes == null || m_Count == 0) return string.Empty; + return System.Text.Encoding.UTF8.GetString(m_bytes, 0, m_Count); + } + } + + public PooledBuffer() + { + m_bytes = null; + m_Count = 0; + } + + public void SetBytesFromMemoryStream(MemoryStream ms) + { + if (ms == null) return; + if (ms.Length == 0) return; + EnsureFixedCapacity((int)ms.Length); + ms.Read(m_bytes, 0, (int)ms.Length); + m_Count = (int)ms.Length; + } + + public void Write(byte[] data, int dataOffset, int dataLength, int index) + { + var totalLength = index + dataLength; + EnsureFixedCapacity(totalLength); + Buffer.BlockCopy(data, dataOffset, m_bytes, index, dataLength); + m_Count = totalLength; + } + + public void Write(IntPtr data, int dataOffset, int dataLength) + { + var totalLength = dataLength; + EnsureFixedCapacity(totalLength); + System.Runtime.InteropServices.Marshal.Copy(data, m_bytes, dataOffset, dataLength); + m_Count = totalLength; + } + + public void Write(string str, int index) + { + var dataLength = index + str.Length; + EnsureFixedCapacity(dataLength); + // fill utf-8 bytes + System.Text.Encoding.UTF8.GetBytes(str, 0, str.Length, m_bytes, index); + m_Count = dataLength; + } + + public void Write(byte b, int index) + { + var dataLength = index + 1; + EnsureFixedCapacity(dataLength); + m_bytes[index] = b; + if (m_Count < dataLength) m_Count = dataLength; + } + + public void EnsureFixedCapacity(int count) + { + if (m_bytes == null || m_bytes.Length < count) + { + // 从池中取出新的数组 + var newBytes = ByteArrayPool.Shared.Get(count); + if (m_bytes != null) + { + // 将旧数组的数据拷贝到新数组 + Buffer.BlockCopy(m_bytes, 0, newBytes, 0, m_Count); + // 将旧数组归还到池中 + ByteArrayPool.Shared.Return(ref m_bytes); + } + m_bytes = newBytes; + } + } + + public void Resize(int count) + { + EnsureFixedCapacity(count); + m_Count = count; + } + + public void Clear() + { + ByteArrayPool.Shared.Return(ref m_bytes); + + m_bytes = null; + m_Count = 0; + } + + public static readonly Queue Pool = new Queue(); + + public static PooledBuffer Create() + { + PooledBuffer buffer; + if (Pool.Count > 0) + { +#if UNITY_WEB_SOCKET_LOG + UnityEngine.Debug.Log($"PooledBuffer Get Reuse"); +#endif + buffer = Pool.Dequeue(); + } + else + { +#if UNITY_WEB_SOCKET_LOG + UnityEngine.Debug.Log($"PooledBuffer Get Alloc"); +#endif + buffer = new PooledBuffer(); + } + buffer.m_Disposed = false; + + return buffer; + } + + public static PooledBuffer Create(Opcode opcode, byte[] data, int offset, int length) + { + var buffer = Create(); + buffer.Opcode = opcode; + buffer.Write(data, offset, length, 0); + return buffer; + } + + public static PooledBuffer Create(Opcode opcode) + { + var buffer = Create(); + buffer.Opcode = opcode; + return buffer; + } + + public void Dispose() + { + if (m_Disposed) return; + m_Disposed = true; + Clear(); + Pool.Enqueue(this); + } + + public static void ClearPool() + { + while (Pool.Count > 0) + { + var buffer = Pool.Dequeue(); + buffer.Clear(); + } + } + } +} \ No newline at end of file diff --git a/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/PooledBuffer.cs.meta b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/PooledBuffer.cs.meta new file mode 100644 index 00000000..d396f248 --- /dev/null +++ b/Assets/UnityWebSocket/Scripts/Runtime/PooledBuffer/PooledBuffer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 48c33cdc3fbb440a98d7542f1e169eb8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json index 2258d367..6f1b042d 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,5 +1,16 @@ { "dependencies": { + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.ai.navigation": "1.1.5", + "com.unity.ide.rider": "3.0.31", + "com.unity.ide.visualstudio": "2.0.22", + "com.unity.ide.vscode": "1.2.5", + "com.unity.memoryprofiler": "1.1.2", + "com.unity.test-framework": "1.1.33", + "com.unity.timeline": "1.7.6", + "com.unity.ugui": "1.0.0", + "com.unity.xr.legacyinputhelpers": "2.1.10", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 40d94a18..1ab26e88 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,5 +1,176 @@ { "dependencies": { + "com.unity.2d.sprite": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.2d.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.uielements": "1.0.0" + } + }, + "com.unity.ai.navigation": { + "version": "1.1.5", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.ai": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.burst": { + "version": "1.8.16", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.mathematics": "1.2.1", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.collections": { + "version": "2.1.1", + "depth": 1, + "source": "registry", + "dependencies": { + "com.unity.burst": "1.8.4", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.nuget.mono-cecil": "1.11.4", + "com.unity.test-framework": "1.3.3", + "com.unity.test-framework.performance": "3.0.0-pre.1" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.editorcoroutines": { + "version": "1.0.0", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.ext.nunit": { + "version": "2.0.3", + "depth": 3, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.ide.rider": { + "version": "3.0.31", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.6" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.ide.visualstudio": { + "version": "2.0.22", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.9" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.ide.vscode": { + "version": "1.2.5", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.mathematics": { + "version": "1.2.6", + "depth": 2, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.memoryprofiler": { + "version": "1.1.2", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.editorcoroutines": "1.0.0", + "com.unity.collections": "2.1.1", + "com.unity.burst": "1.8.0", + "com.unity.profiling.core": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.nuget.mono-cecil": { + "version": "1.11.4", + "depth": 2, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.profiling.core": { + "version": "1.0.2", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.cn" + }, + "com.unity.test-framework": { + "version": "1.3.3", + "depth": 2, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "2.0.3", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.test-framework.performance": { + "version": "3.0.0-pre.1", + "depth": 2, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.31", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.timeline": { + "version": "1.7.6", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.director": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, + "com.unity.ugui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0" + } + }, + "com.unity.xr.legacyinputhelpers": { + "version": "2.1.10", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.xr": "1.0.0" + }, + "url": "https://packages.unity.cn" + }, "com.unity.modules.ai": { "version": "1.0.0", "depth": 0, @@ -133,6 +304,7 @@ "depth": 0, "source": "builtin", "dependencies": { + "com.unity.modules.ui": "1.0.0", "com.unity.modules.imgui": "1.0.0", "com.unity.modules.jsonserialize": "1.0.0" } diff --git a/ProjectSettings/BurstAotSettings_Android.json b/ProjectSettings/BurstAotSettings_Android.json new file mode 100644 index 00000000..ce2d8aa9 --- /dev/null +++ b/ProjectSettings/BurstAotSettings_Android.json @@ -0,0 +1,17 @@ +{ + "MonoBehaviour": { + "Version": 4, + "EnableBurstCompilation": true, + "EnableOptimisations": true, + "EnableSafetyChecks": false, + "EnableDebugInAllBuilds": false, + "DebugDataKind": 1, + "EnableArmv9SecurityFeatures": false, + "CpuMinTargetX32": 0, + "CpuMaxTargetX32": 0, + "CpuMinTargetX64": 0, + "CpuMaxTargetX64": 0, + "CpuTargetsArm64": 512, + "OptimizeFor": 0 + } +} diff --git a/ProjectSettings/CommonBurstAotSettings.json b/ProjectSettings/CommonBurstAotSettings.json new file mode 100644 index 00000000..0293dafc --- /dev/null +++ b/ProjectSettings/CommonBurstAotSettings.json @@ -0,0 +1,6 @@ +{ + "MonoBehaviour": { + "Version": 4, + "DisabledWarnings": "" + } +} diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 2f167c60..fd26ebf6 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -6,6 +6,6 @@ EditorBuildSettings: serializedVersion: 2 m_Scenes: - enabled: 1 - path: Assets/UnityWebSocket/Demo/DemoScene.unity - guid: 65671216fb4e42d4f89ed6eeca36060d + path: Assets/UnityWebSocket/Demo/PerformaceTest.unity + guid: a50f5f77b5b30b1479ae3fd2d7cd89a7 m_configObjects: {} diff --git a/ProjectSettings/MemorySettings.asset b/ProjectSettings/MemorySettings.asset new file mode 100644 index 00000000..5b5facec --- /dev/null +++ b/ProjectSettings/MemorySettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!387306366 &1 +MemorySettings: + m_ObjectHideFlags: 0 + m_EditorMemorySettings: + m_MainAllocatorBlockSize: -1 + m_ThreadAllocatorBlockSize: -1 + m_MainGfxBlockSize: -1 + m_ThreadGfxBlockSize: -1 + m_CacheBlockSize: -1 + m_TypetreeBlockSize: -1 + m_ProfilerBlockSize: -1 + m_ProfilerEditorBlockSize: -1 + m_BucketAllocatorGranularity: -1 + m_BucketAllocatorBucketsCount: -1 + m_BucketAllocatorBlockSize: -1 + m_BucketAllocatorBlockCount: -1 + m_ProfilerBucketAllocatorGranularity: -1 + m_ProfilerBucketAllocatorBucketsCount: -1 + m_ProfilerBucketAllocatorBlockSize: -1 + m_ProfilerBucketAllocatorBlockCount: -1 + m_TempAllocatorSizeMain: -1 + m_JobTempAllocatorBlockSize: -1 + m_BackgroundJobTempAllocatorBlockSize: -1 + m_JobTempAllocatorReducedBlockSize: -1 + m_TempAllocatorSizeGIBakingWorker: -1 + m_TempAllocatorSizeNavMeshWorker: -1 + m_TempAllocatorSizeAudioWorker: -1 + m_TempAllocatorSizeCloudWorker: -1 + m_TempAllocatorSizeGfx: -1 + m_TempAllocatorSizeJobWorker: -1 + m_TempAllocatorSizeBackgroundWorker: -1 + m_TempAllocatorSizePreloadManager: -1 + m_PlatformMemorySettings: {} diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset new file mode 100644 index 00000000..c9f48d57 --- /dev/null +++ b/ProjectSettings/PackageManagerSettings.asset @@ -0,0 +1,36 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 53 + 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: 13964, guid: 0000000000000000e000000000000000, type: 0} + m_Name: + m_EditorClassIdentifier: + m_EnablePreReleasePackages: 0 + m_AdvancedSettingsExpanded: 1 + m_ScopedRegistriesSettingsExpanded: 1 + m_SeeAllPackageVersions: 0 + m_DismissPreviewPackagesInUse: 0 + oneTimeWarningShown: 0 + m_Registries: + - m_Id: main + m_Name: + m_Url: https://packages.unity.cn + m_Scopes: [] + m_IsDefault: 1 + m_Capabilities: 7 + m_ConfigSource: 0 + m_UserSelectedRegistryName: + m_UserAddingNewScopedRegistry: 0 + m_RegistryInfoDraft: + m_Modified: 0 + m_ErrorMessage: + m_UserModificationsInstanceId: -840 + m_OriginalInstanceId: -842 + m_LoadAssets: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 6e7ad0f2..3d803089 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 18 + serializedVersion: 26 productGUID: 5293469bee108a549bc87040c1aa74f5 AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -41,12 +41,6 @@ PlayerSettings: height: 1 m_SplashScreenLogos: [] m_VirtualRealitySplashScreen: {fileID: 0} - m_ShowUnitySplashAds: 0 - m_AdsAndroidGameId: - m_AdsIosGameId: - m_ShowSplashAdsSlogan: 0 - m_SloganImage: {fileID: 0} - m_SloganHeight: 150 m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1024 defaultScreenHeight: 768 @@ -54,13 +48,16 @@ PlayerSettings: defaultScreenHeightWeb: 600 m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 + unsupportedMSAAFallback: 0 + m_SpriteBatchVertexThreshold: 300 m_MTRendering: 1 + mipStripping: 0 + numberOfMipsStripped: 0 + numberOfMipsStrippedPerMipmapLimitGroup: {} m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - displayResolutionDialog: 1 iosUseCustomAppBackgroundBehavior: 0 - iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 allowedAutorotateToLandscapeRight: 1 @@ -71,7 +68,15 @@ PlayerSettings: disableDepthAndStencilBuffers: 0 androidStartInFullscreen: 1 androidRenderOutsideSafeArea: 0 + androidUseSwappy: 0 androidBlitType: 0 + androidResizableWindow: 0 + androidDefaultWindowWidth: 1920 + androidDefaultWindowHeight: 1080 + androidMinimumWindowWidth: 400 + androidMinimumWindowHeight: 300 + androidFullscreenMode: 1 + androidAutoRotationBehavior: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 @@ -83,13 +88,14 @@ PlayerSettings: hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 + dedicatedServerOptimizations: 0 bakeCollisionMeshes: 0 forceSingleInstance: 0 + useFlipModelSwapchain: 1 resizableWindow: 0 useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games gpuSkinning: 0 - graphicsJobs: 0 xboxPIXTextureCapture: 0 xboxEnableAvatar: 0 xboxEnableKinect: 0 @@ -97,7 +103,6 @@ PlayerSettings: xboxEnableFitness: 0 visibleInBackground: 1 allowFullscreenSwitch: 1 - graphicsJobMode: 0 fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 @@ -118,16 +123,22 @@ PlayerSettings: switchNVNShaderPoolsGranularity: 33554432 switchNVNDefaultPoolsGranularity: 16777216 switchNVNOtherPoolsGranularity: 16777216 + switchGpuScratchPoolGranularity: 2097152 + switchAllowGpuScratchShrinking: 0 switchNVNMaxPublicTextureIDCount: 0 switchNVNMaxPublicSamplerIDCount: 0 + switchNVNGraphicsFirmwareMemory: 32 + switchMaxWorkerMultiple: 8 + stadiaPresentMode: 0 + stadiaTargetFramerate: 0 + vulkanNumSwapchainBuffers: 3 vulkanEnableSetSRGBWrite: 0 - useSecurityBuild: 0 - m_SupportedAspectRatios: - 4:3: 1 - 5:4: 1 - 16:10: 1 - 16:9: 1 - Others: 1 + vulkanEnablePreTransform: 0 + vulkanEnableLateAcquireNextImage: 0 + vulkanEnableCommandBufferRecycling: 1 + loadStoreDebugModeEnabled: 0 + visionOSBundleVersion: 1.0 + tvOSBundleVersion: 1.0 bundleVersion: 2.8.1 preloadedAssets: [] metroInputSource: 0 @@ -135,41 +146,30 @@ PlayerSettings: m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 xboxOneEnable7thCore: 0 - isWsaHolographicRemotingEnabled: 0 vrSettings: - cardboard: - depthFormat: 0 - enableTransitionView: 0 - daydream: - depthFormat: 0 - useSustainedPerformanceMode: 0 - enableVideoLayer: 0 - useProtectedVideoMemory: 0 - minimumSupportedHeadTracking: 0 - maximumSupportedHeadTracking: 1 - hololens: - depthFormat: 1 - depthBufferSharingEnabled: 0 - oculus: - sharedDepthBuffer: 0 - dashSupport: 0 - lowOverheadMode: 0 - protectedContext: 0 - v2Signing: 0 enable360StereoCapture: 0 - protectGraphicsMemory: 0 + isWsaHolographicRemotingEnabled: 0 enableFrameTimingStats: 0 + enableOpenGLProfilerGPURecorders: 1 + allowHDRDisplaySupport: 0 useHDRDisplay: 0 + hdrBitDepth: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 + resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 applicationIdentifier: Android: com.redstone.UnityWebsocket - buildNumber: {} + buildNumber: + Standalone: 0 + VisionOS: 0 + iPhone: 0 + tvOS: 0 + overrideDefaultApplicationIdentifier: 1 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 16 + AndroidMinSdkVersion: 22 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: @@ -182,30 +182,21 @@ PlayerSettings: APKExpansionFiles: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 + strictShaderVariantMatching: 0 VertexChannelCompressionMask: 214 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 9.0 + iOSTargetOSVersionString: 12.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 9.0 + tvOSTargetOSVersionString: 12.0 + VisionOSSdkVersion: 0 + VisionOSTargetOSVersionString: 1.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 uIStatusBarHidden: 1 uIExitOnSuspend: 0 uIStatusBarStyle: 0 - iPhoneSplashScreen: {fileID: 0} - iPhoneHighResSplashScreen: {fileID: 0} - iPhoneTallHighResSplashScreen: {fileID: 0} - iPhone47inSplashScreen: {fileID: 0} - iPhone55inPortraitSplashScreen: {fileID: 0} - iPhone55inLandscapeSplashScreen: {fileID: 0} - iPhone58inPortraitSplashScreen: {fileID: 0} - iPhone58inLandscapeSplashScreen: {fileID: 0} - iPadPortraitSplashScreen: {fileID: 0} - iPadHighResPortraitSplashScreen: {fileID: 0} - iPadLandscapeSplashScreen: {fileID: 0} - iPadHighResLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] @@ -233,60 +224,229 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: - iOSUseLaunchScreenStoryboard: 0 iOSLaunchScreenCustomStoryboardPath: + iOSLaunchScreeniPadCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] + macOSURLSchemes: [] iOSBackgroundModes: 0 iOSMetalForceHardShadows: 0 metalEditorSupport: 1 metalAPIValidation: 1 + metalCompileShaderBinary: 0 iOSRenderExtraFrameOnPause: 0 + iosCopyPluginsCodeInsteadOfSymlink: 0 appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + VisionOSManualSigningProvisioningProfileID: iOSManualSigningProvisioningProfileType: 0 tvOSManualSigningProvisioningProfileType: 0 + VisionOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 iOSRequireARKit: 0 iOSAutomaticallyDetectAndAddCapabilities: 1 appleEnableProMotion: 0 + shaderPrecisionModel: 0 clonedFromGUID: 00000000000000000000000000000000 templatePackageId: templateDefaultScene: + useCustomMainManifest: 0 + useCustomLauncherManifest: 0 + useCustomMainGradleTemplate: 0 + useCustomLauncherGradleManifest: 0 + useCustomBaseGradleTemplate: 0 + useCustomGradlePropertiesTemplate: 0 + useCustomGradleSettingsTemplate: 0 + useCustomProguardFile: 0 AndroidTargetArchitectures: 5 + AndroidTargetDevices: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: + AndroidEnableArmv9SecurityFeatures: 0 AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 1 AndroidIsGame: 1 AndroidEnableTango: 0 androidEnableBanner: 1 androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 m_AndroidBanners: - width: 320 height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 - resolutionDialogBanner: {fileID: 0} + chromeosInputEmulation: 1 + AndroidMinifyRelease: 0 + AndroidMinifyDebug: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 200 m_BuildTargetIcons: [] - m_BuildTargetPlatformIcons: [] + m_BuildTargetPlatformIcons: + - m_BuildTarget: Android + m_Icons: + - m_Textures: [] + m_Width: 432 + m_Height: 432 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 324 + m_Height: 324 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 216 + m_Height: 216 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 162 + m_Height: 162 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 108 + m_Height: 108 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 81 + m_Height: 81 + m_Kind: 2 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 1 + m_SubKind: + - m_Textures: [] + m_Width: 192 + m_Height: 192 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 144 + m_Height: 144 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 96 + m_Height: 96 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 72 + m_Height: 72 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 48 + m_Height: 48 + m_Kind: 0 + m_SubKind: + - m_Textures: [] + m_Width: 36 + m_Height: 36 + m_Kind: 0 + m_SubKind: m_BuildTargetBatching: [] - m_BuildTargetEncrypting: [] - m_BuildTargetGraphicsAPIs: [] + m_BuildTargetShaderSettings: [] + m_BuildTargetGraphicsJobs: + - m_BuildTarget: WindowsStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: MacStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: LinuxStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AndroidPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: iOSSupport + m_GraphicsJobs: 0 + - m_BuildTarget: PS4Player + m_GraphicsJobs: 0 + - m_BuildTarget: PS5Player + m_GraphicsJobs: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobs: 0 + - m_BuildTarget: GameCoreXboxOneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: GameCoreScarlettSupport + m_GraphicsJobs: 0 + - m_BuildTarget: Switch + m_GraphicsJobs: 0 + - m_BuildTarget: WebGLSupport + m_GraphicsJobs: 0 + - m_BuildTarget: MetroSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AppleTVSupport + m_GraphicsJobs: 0 + - m_BuildTarget: VisionOSPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: BJMSupport + m_GraphicsJobs: 0 + - m_BuildTarget: CloudRendering + m_GraphicsJobs: 0 + - m_BuildTarget: EmbeddedLinux + m_GraphicsJobs: 0 + - m_BuildTarget: QNX + m_GraphicsJobs: 0 + m_BuildTargetGraphicsJobMode: + - m_BuildTarget: PS4Player + m_GraphicsJobMode: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobMode: 0 + m_BuildTargetGraphicsAPIs: + - m_BuildTarget: iOSSupport + m_APIs: 10000000 + m_Automatic: 1 + - m_BuildTarget: AndroidPlayer + m_APIs: 0b00000008000000 + m_Automatic: 0 m_BuildTargetVRSettings: [] - m_BuildTargetEnableVuforiaSettings: [] + m_DefaultShaderChunkSizeInMB: 16 + m_DefaultShaderChunkCount: 0 openGLRequireES31: 0 openGLRequireES31AEP: 0 + openGLRequireES32: 0 m_TemplateCustomTags: {} mobileMTRendering: Android: 1 iPhone: 1 tvOS: 1 m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupHDRCubemapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] + m_BuildTargetGroupLoadStoreDebugModeSettings: [] + m_BuildTargetNormalMapEncoding: [] + m_BuildTargetDefaultTextureCompressionFormat: [] playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 @@ -296,14 +456,20 @@ PlayerSettings: cameraUsageDescription: locationUsageDescription: microphoneUsageDescription: + bluetoothUsageDescription: + macOSTargetOSVersion: 10.13.0 + switchNMETAOverride: switchNetLibKey: switchSocketMemoryPoolSize: 6144 switchSocketAllocatorPoolSize: 128 switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 + switchEnableFileSystemTrace: 0 + switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: + switchCompilerFlags: switchTitleNames_0: switchTitleNames_1: switchTitleNames_2: @@ -319,6 +485,7 @@ PlayerSettings: switchTitleNames_12: switchTitleNames_13: switchTitleNames_14: + switchTitleNames_15: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -334,6 +501,7 @@ PlayerSettings: switchPublisherNames_12: switchPublisherNames_13: switchPublisherNames_14: + switchPublisherNames_15: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -349,6 +517,7 @@ PlayerSettings: switchIcons_12: {fileID: 0} switchIcons_13: {fileID: 0} switchIcons_14: {fileID: 0} + switchIcons_15: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -364,6 +533,7 @@ PlayerSettings: switchSmallIcons_12: {fileID: 0} switchSmallIcons_13: {fileID: 0} switchSmallIcons_14: {fileID: 0} + switchSmallIcons_15: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -373,7 +543,6 @@ PlayerSettings: switchReleaseVersion: 0 switchDisplayVersion: 1.0.0 switchStartupUserAccount: 0 - switchTouchScreenUsage: 0 switchSupportedLanguagesMask: 0 switchLogoType: 0 switchApplicationErrorCodeCategory: @@ -415,6 +584,7 @@ PlayerSettings: switchNativeFsCacheSize: 32 switchIsHoldTypeHorizontal: 0 switchSupportedNpadCount: 8 + switchEnableTouchScreen: 1 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -425,7 +595,12 @@ PlayerSettings: switchSocketBufferEfficiency: 4 switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 - switchPlayerConnectionEnabled: 1 + switchUseNewStyleFilepaths: 1 + switchUseLegacyFmodPriorities: 0 + switchUseMicroSleepForYield: 1 + switchEnableRamDiskSupport: 0 + switchMicroSleepForYieldTime: 25 + switchRamDiskSpaceSize: 12 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -465,6 +640,7 @@ PlayerSettings: ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ ps4pnSessions: 1 ps4pnPresence: 1 @@ -477,6 +653,7 @@ PlayerSettings: ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 ps4UseAudio3dBackend: 0 + ps4UseLowGarlicFragmentationMode: 1 ps4SocialScreenEnabled: 0 ps4ScriptOptimizationLevel: 0 ps4Audio3dVirtualSpeakerCount: 14 @@ -494,16 +671,20 @@ PlayerSettings: ps4videoRecordingFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0 ps4CompatibilityPS5: 0 + ps4AllowPS5Detection: 0 ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] + ps4attribVROutputEnabled: 0 monoEnv: splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 spritePackerPolicy: webGLMemorySize: 256 webGLExceptionSupport: 1 webGLNameFilesAsHashes: 0 + webGLShowDiagnostics: 0 webGLDataCaching: 0 webGLDebugSymbols: 0 webGLEmscriptenArgs: @@ -512,19 +693,48 @@ PlayerSettings: webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 webGLCompressionFormat: 1 + webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0 + webGLDecompressionFallback: 0 + webGLInitialMemorySize: 32 + webGLMaximumMemorySize: 2048 + webGLMemoryGrowthMode: 2 + webGLMemoryLinearGrowthStep: 16 + webGLMemoryGeometricGrowthStep: 0.2 + webGLMemoryGeometricGrowthCap: 96 + webGLPowerPreference: 2 scriptingDefineSymbols: - 1: + Standalone: + additionalCompilerArguments: {} platformArchitecture: {} scriptingBackend: Standalone: 0 il2cppCompilerConfiguration: {} - managedStrippingLevel: {} + il2cppCodeGeneration: {} + managedStrippingLevel: + EmbeddedLinux: 1 + GameCoreScarlett: 1 + GameCoreXboxOne: 1 + Nintendo Switch: 1 + PS4: 1 + PS5: 1 + QNX: 1 + Stadia: 1 + VisionOS: 1 + WebGL: 1 + Windows Store Apps: 1 + XboxOne: 1 + iPhone: 1 + tvOS: 1 incrementalIl2cppBuild: {} + suppressCommonWarnings: 1 allowUnsafeCode: 0 + useDeterministicCompilation: 1 additionalIl2CppArgs: scriptingRuntimeVersion: 1 + gcIncremental: 1 + gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: {} m_RenderingPath: 1 m_MobileRenderingPath: 1 @@ -550,12 +760,13 @@ PlayerSettings: metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, a: 1} metroSplashScreenUseBackgroundColor: 0 + syncCapabilities: 0 platformCapabilities: {} metroTargetDeviceFamilies: {} metroFTAName: metroFTAFileTypes: [] metroProtocolName: - metroCompilationOverrides: 1 + vcxProjDefaultLanguage: XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -574,18 +785,16 @@ PlayerSettings: XboxOneCapability: [] XboxOneGameRating: {} XboxOneIsContentPackage: 0 + XboxOneEnhancedXboxCompatibilityMode: 0 XboxOneEnableGPUVariability: 0 XboxOneSockets: {} XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - xboxOneScriptCompiler: 0 XboxOneOverrideIdentityName: - vrEditorSettings: - daydream: - daydreamIconForeground: {fileID: 0} - daydreamIconBackground: {fileID: 0} + XboxOneOverrideIdentityPublisher: + vrEditorSettings: {} cloudServicesEnabled: {} luminIcon: m_Name: @@ -593,24 +802,27 @@ PlayerSettings: m_PortalFolderPath: luminCert: m_CertPath: - m_PrivateKeyPath: + m_SignPackage: 1 luminIsChannelApp: 0 luminVersion: m_VersionCode: 1 m_VersionName: - facebookSdkVersion: 7.9.4 - facebookAppId: - facebookCookies: 1 - facebookLogging: 1 - facebookStatus: 1 - facebookXfbml: 0 - facebookFrictionlessRequests: 1 + hmiPlayerDataPath: + hmiForceSRGBBlit: 1 + embeddedLinuxEnableGamepadInput: 1 + hmiLogStartupTiming: 0 + hmiCpuConfiguration: apiCompatibilityLevel: 6 + activeInputHandler: 0 + windowsGamepadBackendHint: 0 cloudProjectId: framebufferDepthMemorylessMode: 0 + qualitySettingsNames: [] projectName: organizationId: cloudEnabled: 0 - enableNativePlatformBackendsForNewInputSystem: 0 - disableOldInputManagerSupport: 0 legacyClampBlendShapeWeights: 1 + hmiLoadingImage: {fileID: 0} + platformRequiresReadableAssets: 0 + virtualTexturingSupportEnabled: 0 + insecureHttpOption: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index ca463ed3..98ad9a7f 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1 +1,2 @@ -m_EditorVersion: 2018.4.27f1 +m_EditorVersion: 2022.3.40f1c1 +m_EditorVersionWithRevision: 2022.3.40f1c1 (0bae6c114c78) diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json new file mode 100644 index 00000000..5e97f839 --- /dev/null +++ b/ProjectSettings/SceneTemplateSettings.json @@ -0,0 +1,121 @@ +{ + "templatePinStates": [], + "dependencyTypeInfos": [ + { + "userAdded": false, + "type": "UnityEngine.AnimationClip", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Animations.AnimatorController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.AnimatorOverrideController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.Audio.AudioMixerController", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.ComputeShader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Cubemap", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.GameObject", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.LightingDataAsset", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.LightingSettings", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Material", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.MonoScript", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicMaterial", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.PhysicsMaterial2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Rendering.VolumeProfile", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEditor.SceneAsset", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Shader", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.ShaderVariantCollection", + "defaultInstantiationMode": 1 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Texture2D", + "defaultInstantiationMode": 0 + }, + { + "userAdded": false, + "type": "UnityEngine.Timeline.TimelineAsset", + "defaultInstantiationMode": 0 + } + ], + "defaultDependencyTypeInfo": { + "userAdded": false, + "type": "", + "defaultInstantiationMode": 1 + }, + "newSceneOverride": 0 +} \ No newline at end of file diff --git a/ProjectSettings/VersionControlSettings.asset b/ProjectSettings/VersionControlSettings.asset new file mode 100644 index 00000000..dca28814 --- /dev/null +++ b/ProjectSettings/VersionControlSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!890905787 &1 +VersionControlSettings: + m_ObjectHideFlags: 0 + m_Mode: Visible Meta Files + m_CollabEditorSettings: + inProgressEnabled: 1