├── .gitignore ├── Assets ├── UnityWebSocket.meta └── UnityWebSocket │ ├── Demo.meta │ ├── Demo │ ├── DemoScene.unity │ ├── DemoScene.unity.meta │ ├── UnityWebSocketDemo.cs │ └── UnityWebSocketDemo.cs.meta │ ├── Plugins.meta │ ├── Plugins │ ├── WebGL.meta │ └── WebGL │ │ ├── WebSocket.jslib │ │ └── WebSocket.jslib.meta │ ├── Scripts.meta │ └── Scripts │ ├── Editor.meta │ ├── Editor │ ├── SettingsWindow.cs │ ├── SettingsWindow.cs.meta │ ├── UnityWebSocket.Editor.asmdef │ └── UnityWebSocket.Editor.asmdef.meta │ ├── Runtime.meta │ └── Runtime │ ├── Core.meta │ ├── Core │ ├── CloseEventArgs.cs │ ├── CloseEventArgs.cs.meta │ ├── CloseStatusCode.cs │ ├── CloseStatusCode.cs.meta │ ├── ErrorEventArgs.cs │ ├── ErrorEventArgs.cs.meta │ ├── IWebSocket.cs │ ├── IWebSocket.cs.meta │ ├── MessageEventArgs.cs │ ├── MessageEventArgs.cs.meta │ ├── Opcode.cs │ ├── Opcode.cs.meta │ ├── OpenEventArgs.cs │ ├── OpenEventArgs.cs.meta │ ├── Settings.cs │ ├── Settings.cs.meta │ ├── WebSocketState.cs │ └── WebSocketState.cs.meta │ ├── Implementation.meta │ ├── Implementation │ ├── NoWebGL.meta │ ├── NoWebGL │ │ ├── WebSocket.cs │ │ ├── WebSocket.cs.meta │ │ ├── WebSocketManager.cs │ │ └── WebSocketManager.cs.meta │ ├── WebGL.meta │ └── WebGL │ │ ├── WebSocket.cs │ │ ├── WebSocket.cs.meta │ │ ├── WebSocketManager.cs │ │ └── WebSocketManager.cs.meta │ ├── UnityWebSocket.Runtime.asmdef │ └── UnityWebSocket.Runtime.asmdef.meta ├── CHANGE_LOG.md ├── LICENSE ├── Packages ├── manifest.json └── packages-lock.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UPRSettings.asset ├── UnityConnectSettings.asset ├── VFXManager.asset └── XRSettings.asset ├── README.md └── README_EN.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | [Ll]ibrary/ 3 | 4 | [Tt]emp/ 5 | 6 | [Oo]bj/ 7 | 8 | [Bb]uilds/ 9 | 10 | [Ll]ogs/ 11 | 12 | bin/ 13 | 14 | # Visual Studio 2017 cache directory 15 | 16 | .vs/ 17 | 18 | *.csproj 19 | 20 | *.sln 21 | .vsconfig 22 | Build/ 23 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a48e5bab43b85341bcf6c0f41824959 3 | folderAsset: yes 4 | timeCreated: 1530672403 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aab4c0dd88d44cd4e817c3f1994407b4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Demo/DemoScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 9 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | m_UseRadianceAmbientProbe: 0 43 | --- !u!157 &3 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 11 47 | m_GIWorkflowMode: 1 48 | m_GISettings: 49 | serializedVersion: 2 50 | m_BounceScale: 1 51 | m_IndirectOutputScale: 1 52 | m_AlbedoBoost: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 10 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_AtlasSize: 1024 61 | m_AO: 0 62 | m_AOMaxDistance: 1 63 | m_CompAOExponent: 1 64 | m_CompAOExponentDirect: 0 65 | m_Padding: 2 66 | m_LightmapParameters: {fileID: 0} 67 | m_LightmapsBakeMode: 1 68 | m_TextureCompression: 1 69 | m_FinalGather: 0 70 | m_FinalGatherFiltering: 1 71 | m_FinalGatherRayCount: 256 72 | m_ReflectionCompression: 2 73 | m_MixedBakeMode: 2 74 | m_BakeBackend: 1 75 | m_PVRSampling: 1 76 | m_PVRDirectSampleCount: 32 77 | m_PVRSampleCount: 500 78 | m_PVRBounces: 2 79 | m_PVRFilterTypeDirect: 0 80 | m_PVRFilterTypeIndirect: 0 81 | m_PVRFilterTypeAO: 0 82 | m_PVRFilteringMode: 2 83 | m_PVRCulling: 1 84 | m_PVRFilteringGaussRadiusDirect: 1 85 | m_PVRFilteringGaussRadiusIndirect: 5 86 | m_PVRFilteringGaussRadiusAO: 2 87 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5 88 | m_PVRFilteringAtrousPositionSigmaIndirect: 2 89 | m_PVRFilteringAtrousPositionSigmaAO: 1 90 | m_ShowResolutionOverlay: 1 91 | m_LightingDataAsset: {fileID: 0} 92 | m_UseShadowmask: 1 93 | --- !u!196 &4 94 | NavMeshSettings: 95 | serializedVersion: 2 96 | m_ObjectHideFlags: 0 97 | m_BuildSettings: 98 | serializedVersion: 2 99 | agentTypeID: 0 100 | agentRadius: 0.5 101 | agentHeight: 2 102 | agentSlope: 45 103 | agentClimb: 0.4 104 | ledgeDropHeight: 0 105 | maxJumpAcrossDistance: 0 106 | minRegionArea: 2 107 | manualCellSize: 0 108 | cellSize: 0.16666667 109 | manualTileSize: 0 110 | tileSize: 256 111 | accuratePlacement: 0 112 | debug: 113 | m_Flags: 0 114 | m_NavMeshData: {fileID: 0} 115 | --- !u!1 &516737225 116 | GameObject: 117 | m_ObjectHideFlags: 0 118 | m_CorrespondingSourceObject: {fileID: 0} 119 | m_PrefabInstance: {fileID: 0} 120 | m_PrefabAsset: {fileID: 0} 121 | serializedVersion: 6 122 | m_Component: 123 | - component: {fileID: 516737226} 124 | - component: {fileID: 516737227} 125 | m_Layer: 0 126 | m_Name: Main 127 | m_TagString: Untagged 128 | m_Icon: {fileID: 0} 129 | m_NavMeshLayer: 0 130 | m_StaticEditorFlags: 0 131 | m_IsActive: 1 132 | --- !u!4 &516737226 133 | Transform: 134 | m_ObjectHideFlags: 0 135 | m_CorrespondingSourceObject: {fileID: 0} 136 | m_PrefabInstance: {fileID: 0} 137 | m_PrefabAsset: {fileID: 0} 138 | m_GameObject: {fileID: 516737225} 139 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 140 | m_LocalPosition: {x: 0, y: 0, z: 0} 141 | m_LocalScale: {x: 1, y: 1, z: 1} 142 | m_Children: [] 143 | m_Father: {fileID: 0} 144 | m_RootOrder: 1 145 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 146 | --- !u!114 &516737227 147 | MonoBehaviour: 148 | m_ObjectHideFlags: 0 149 | m_CorrespondingSourceObject: {fileID: 0} 150 | m_PrefabInstance: {fileID: 0} 151 | m_PrefabAsset: {fileID: 0} 152 | m_GameObject: {fileID: 516737225} 153 | m_Enabled: 1 154 | m_EditorHideFlags: 0 155 | m_Script: {fileID: 11500000, guid: c1b55962346f6de40bd5e924df2854fb, type: 3} 156 | m_Name: 157 | m_EditorClassIdentifier: 158 | address: wss://echo.websocket.events 159 | subProtocols: soap|wamp 160 | sendText: Hello UnityWebSocket! 161 | --- !u!1 &902376145 162 | GameObject: 163 | m_ObjectHideFlags: 0 164 | m_CorrespondingSourceObject: {fileID: 0} 165 | m_PrefabInstance: {fileID: 0} 166 | m_PrefabAsset: {fileID: 0} 167 | serializedVersion: 6 168 | m_Component: 169 | - component: {fileID: 902376148} 170 | - component: {fileID: 902376147} 171 | - component: {fileID: 902376146} 172 | m_Layer: 0 173 | m_Name: Camera 174 | m_TagString: Untagged 175 | m_Icon: {fileID: 0} 176 | m_NavMeshLayer: 0 177 | m_StaticEditorFlags: 0 178 | m_IsActive: 1 179 | --- !u!81 &902376146 180 | AudioListener: 181 | m_ObjectHideFlags: 0 182 | m_CorrespondingSourceObject: {fileID: 0} 183 | m_PrefabInstance: {fileID: 0} 184 | m_PrefabAsset: {fileID: 0} 185 | m_GameObject: {fileID: 902376145} 186 | m_Enabled: 1 187 | --- !u!20 &902376147 188 | Camera: 189 | m_ObjectHideFlags: 0 190 | m_CorrespondingSourceObject: {fileID: 0} 191 | m_PrefabInstance: {fileID: 0} 192 | m_PrefabAsset: {fileID: 0} 193 | m_GameObject: {fileID: 902376145} 194 | m_Enabled: 1 195 | serializedVersion: 2 196 | m_ClearFlags: 2 197 | m_BackGroundColor: {r: 0.3301887, g: 0.3301887, b: 0.3301887, a: 0} 198 | m_projectionMatrixMode: 1 199 | m_SensorSize: {x: 36, y: 24} 200 | m_LensShift: {x: 0, y: 0} 201 | m_GateFitMode: 2 202 | m_FocalLength: 50 203 | m_NormalizedViewPortRect: 204 | serializedVersion: 2 205 | x: 0 206 | y: 0 207 | width: 1 208 | height: 1 209 | near clip plane: 0.3 210 | far clip plane: 1000 211 | field of view: 60 212 | orthographic: 0 213 | orthographic size: 5 214 | m_Depth: 0 215 | m_CullingMask: 216 | serializedVersion: 2 217 | m_Bits: 4294967295 218 | m_RenderingPath: -1 219 | m_TargetTexture: {fileID: 0} 220 | m_TargetDisplay: 0 221 | m_TargetEye: 3 222 | m_HDR: 1 223 | m_AllowMSAA: 1 224 | m_AllowDynamicResolution: 0 225 | m_ForceIntoRT: 0 226 | m_OcclusionCulling: 1 227 | m_StereoConvergence: 10 228 | m_StereoSeparation: 0.022 229 | --- !u!4 &902376148 230 | Transform: 231 | m_ObjectHideFlags: 0 232 | m_CorrespondingSourceObject: {fileID: 0} 233 | m_PrefabInstance: {fileID: 0} 234 | m_PrefabAsset: {fileID: 0} 235 | m_GameObject: {fileID: 902376145} 236 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 237 | m_LocalPosition: {x: 0, y: 0, z: 0} 238 | m_LocalScale: {x: 1, y: 1, z: 1} 239 | m_Children: [] 240 | m_Father: {fileID: 0} 241 | m_RootOrder: 0 242 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 243 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Demo/DemoScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65671216fb4e42d4f89ed6eeca36060d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityWebSocket.Demo 4 | { 5 | public class UnityWebSocketDemo : MonoBehaviour 6 | { 7 | public string address = "wss://echo.websocket.events"; 8 | public string sendText = "Hello UnityWebSocket!"; 9 | 10 | private IWebSocket socket; 11 | 12 | private bool logMessage = true; 13 | private string log = ""; 14 | private int sendCount; 15 | private int receiveCount; 16 | private Vector2 scrollPos; 17 | private Color green = new Color(0.1f, 1, 0.1f); 18 | private Color red = new Color(1f, 0.1f, 0.1f); 19 | private Color wait = new Color(0.7f, 0.3f, 0.3f); 20 | 21 | private void OnGUI() 22 | { 23 | var scale = Screen.width / 800f; 24 | GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(scale, scale, 1)); 25 | var width = GUILayout.Width(Screen.width / scale - 10); 26 | 27 | WebSocketState state = socket == null ? WebSocketState.Closed : socket.ReadyState; 28 | 29 | // draw header 30 | GUILayout.BeginHorizontal(); 31 | GUILayout.Label("SDK Version: " + Settings.VERSION, GUILayout.Width(Screen.width / scale - 100)); 32 | GUI.color = green; 33 | GUILayout.Label($"FPS: {fps:F2}", GUILayout.Width(80)); 34 | GUI.color = Color.white; 35 | GUILayout.EndHorizontal(); 36 | 37 | // draw websocket state 38 | GUILayout.BeginHorizontal(); 39 | GUILayout.Label("State: ", GUILayout.Width(36)); 40 | GUI.color = WebSocketState.Closed == state ? red : WebSocketState.Open == state ? green : wait; 41 | GUILayout.Label($"{state}", GUILayout.Width(120)); 42 | GUI.color = Color.white; 43 | GUILayout.EndHorizontal(); 44 | 45 | // draw address 46 | GUI.enabled = state == WebSocketState.Closed; 47 | GUILayout.Label("Address: ", width); 48 | address = GUILayout.TextField(address, width); 49 | 50 | // draw connect button 51 | GUILayout.BeginHorizontal(); 52 | GUI.enabled = state == WebSocketState.Closed; 53 | if (GUILayout.Button(state == WebSocketState.Connecting ? "Connecting..." : "Connect")) 54 | { 55 | socket = new WebSocket(address); 56 | socket.OnOpen += Socket_OnOpen; 57 | socket.OnMessage += Socket_OnMessage; 58 | socket.OnClose += Socket_OnClose; 59 | socket.OnError += Socket_OnError; 60 | AddLog(string.Format("Connecting...")); 61 | socket.ConnectAsync(); 62 | } 63 | 64 | // draw close button 65 | GUI.enabled = state == WebSocketState.Open; 66 | if (GUILayout.Button(state == WebSocketState.Closing ? "Closing..." : "Close")) 67 | { 68 | AddLog(string.Format("Closing...")); 69 | socket.CloseAsync(); 70 | } 71 | GUILayout.EndHorizontal(); 72 | 73 | // draw input message 74 | GUILayout.Label("Message: "); 75 | sendText = GUILayout.TextArea(sendText, GUILayout.MinHeight(50), width); 76 | 77 | // draw send message button 78 | GUILayout.BeginHorizontal(); 79 | if (GUILayout.Button("Send") && !string.IsNullOrEmpty(sendText)) 80 | { 81 | socket.SendAsync(sendText); 82 | AddLog(string.Format("Send: {0}", sendText)); 83 | sendCount += 1; 84 | } 85 | if (GUILayout.Button("Send Bytes") && !string.IsNullOrEmpty(sendText)) 86 | { 87 | var bytes = System.Text.Encoding.UTF8.GetBytes(sendText); 88 | socket.SendAsync(bytes); 89 | AddLog(string.Format("Send Bytes ({1}): {0}", sendText, bytes.Length)); 90 | sendCount += 1; 91 | } 92 | if (GUILayout.Button("Send x100") && !string.IsNullOrEmpty(sendText)) 93 | { 94 | for (int i = 0; i < 100; i++) 95 | { 96 | var text = (i + 1).ToString() + ". " + sendText; 97 | socket.SendAsync(text); 98 | AddLog(string.Format("Send: {0}", text)); 99 | sendCount += 1; 100 | } 101 | } 102 | if (GUILayout.Button("Send Bytes x100") && !string.IsNullOrEmpty(sendText)) 103 | { 104 | for (int i = 0; i < 100; i++) 105 | { 106 | var text = (i + 1).ToString() + ". " + sendText; 107 | var bytes = System.Text.Encoding.UTF8.GetBytes(text); 108 | socket.SendAsync(bytes); 109 | AddLog(string.Format("Send Bytes ({1}): {0}", text, bytes.Length)); 110 | sendCount += 1; 111 | } 112 | } 113 | GUILayout.EndHorizontal(); 114 | 115 | // draw message count 116 | GUI.enabled = true; 117 | GUILayout.BeginHorizontal(); 118 | logMessage = GUILayout.Toggle(logMessage, "Log Message"); 119 | GUILayout.Label(string.Format("Send Count: {0}", sendCount)); 120 | GUILayout.Label(string.Format("Receive Count: {0}", receiveCount)); 121 | GUILayout.EndHorizontal(); 122 | 123 | // draw clear button 124 | if (GUILayout.Button("Clear")) 125 | { 126 | log = ""; 127 | receiveCount = 0; 128 | sendCount = 0; 129 | } 130 | 131 | // draw message content 132 | scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.MaxHeight(Screen.height / scale - 270), width); 133 | GUILayout.Label(log); 134 | GUILayout.EndScrollView(); 135 | } 136 | 137 | private void AddLog(string str) 138 | { 139 | if (!logMessage) return; 140 | if (str.Length > 100) str = str.Substring(0, 100) + "..."; 141 | log += str + "\n"; 142 | if (log.Length > 22 * 1024) 143 | { 144 | log = log.Substring(log.Length - 22 * 1024); 145 | } 146 | scrollPos.y = int.MaxValue; 147 | } 148 | 149 | private void Socket_OnOpen(object sender, OpenEventArgs e) 150 | { 151 | AddLog(string.Format("Connected: {0}", address)); 152 | } 153 | 154 | private void Socket_OnMessage(object sender, MessageEventArgs e) 155 | { 156 | if (e.IsBinary) 157 | { 158 | AddLog(string.Format("Receive Bytes ({1}): {0}", e.Data, e.RawData.Length)); 159 | } 160 | else if (e.IsText) 161 | { 162 | AddLog(string.Format("Receive: {0}", e.Data)); 163 | } 164 | receiveCount += 1; 165 | } 166 | 167 | private void Socket_OnClose(object sender, CloseEventArgs e) 168 | { 169 | AddLog(string.Format("Closed: StatusCode: {0}, Reason: {1}", e.StatusCode, e.Reason)); 170 | } 171 | 172 | private void Socket_OnError(object sender, ErrorEventArgs e) 173 | { 174 | AddLog(string.Format("Error: {0}", e.Message)); 175 | } 176 | 177 | private int frame = 0; 178 | private float time = 0; 179 | private float fps = 0; 180 | private void Update() 181 | { 182 | frame += 1; 183 | time += Time.deltaTime; 184 | if (time >= 0.5f) 185 | { 186 | fps = frame / time; 187 | frame = 0; 188 | time = 0; 189 | } 190 | } 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1b55962346f6de40bd5e924df2854fb 3 | timeCreated: 1466599118 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4589fa9979d007040b5a807b0304b1ff 3 | folderAsset: yes 4 | timeCreated: 1466577973 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Plugins/WebGL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1a1a6aea65cc413faf8fb4421138b29 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib: -------------------------------------------------------------------------------- 1 | var WebSocketLibrary = 2 | { 3 | $webSocketManager: 4 | { 5 | /* 6 | * Map of instances 7 | * 8 | * Instance structure: 9 | * { 10 | * url: string, 11 | * ws: WebSocket, 12 | * subProtocols: string[], 13 | * } 14 | */ 15 | instances: {}, 16 | 17 | /* Last instance ID */ 18 | lastId: 0, 19 | 20 | /* Event listeners */ 21 | onOpen: null, 22 | onMessage: null, 23 | onMessageStr: null, 24 | onError: null, 25 | onClose: null, 26 | 27 | /* Support Unity 6000 */ 28 | support6000: false 29 | }, 30 | 31 | /** 32 | * Support Unity 6000 33 | * 34 | */ 35 | WebSocketSetSupport6000: function() 36 | { 37 | webSocketManager.support6000 = true; 38 | }, 39 | 40 | /** 41 | * Set onOpen callback 42 | * 43 | * @param callback Reference to C# static function 44 | */ 45 | WebSocketSetOnOpen: function(callback) 46 | { 47 | webSocketManager.onOpen = callback; 48 | }, 49 | 50 | /** 51 | * Set onMessage callback 52 | * 53 | * @param callback Reference to C# static function 54 | */ 55 | WebSocketSetOnMessage: function(callback) 56 | { 57 | webSocketManager.onMessage = callback; 58 | }, 59 | 60 | /** 61 | * Set onMessageStr callback 62 | * 63 | * @param callback Reference to C# static function 64 | */ 65 | WebSocketSetOnMessageStr: function(callback) 66 | { 67 | webSocketManager.onMessageStr = callback; 68 | }, 69 | 70 | /** 71 | * Set onError callback 72 | * 73 | * @param callback Reference to C# static function 74 | */ 75 | WebSocketSetOnError: function(callback) 76 | { 77 | webSocketManager.onError = callback; 78 | }, 79 | 80 | /** 81 | * Set onClose callback 82 | * 83 | * @param callback Reference to C# static function 84 | */ 85 | WebSocketSetOnClose: function(callback) 86 | { 87 | webSocketManager.onClose = callback; 88 | }, 89 | 90 | /** 91 | * Allocate new WebSocket instance struct 92 | * 93 | * @param url Server URL 94 | */ 95 | WebSocketAllocate: function(urlPtr) 96 | { 97 | var url = UTF8ToString(urlPtr); 98 | var id = ++webSocketManager.lastId; 99 | webSocketManager.instances[id] = { 100 | url: url, 101 | ws: null, 102 | }; 103 | 104 | return id; 105 | }, 106 | 107 | /** 108 | * Add Sub Protocol 109 | * 110 | * @param instanceId Instance ID 111 | * @param protocol Sub Protocol 112 | */ 113 | WebSocketAddSubProtocol: function(instanceId, protocolPtr) 114 | { 115 | var instance = webSocketManager.instances[instanceId]; 116 | if (!instance) return -1; 117 | 118 | var protocol = UTF8ToString(protocolPtr); 119 | 120 | if (instance.subProtocols == null) 121 | instance.subProtocols = []; 122 | 123 | instance.subProtocols.push(protocol); 124 | 125 | return 0; 126 | }, 127 | 128 | /** 129 | * Remove reference to WebSocket instance 130 | * 131 | * If socket is not closed function will close it but onClose event will not be emitted because 132 | * this function should be invoked by C# WebSocket destructor. 133 | * 134 | * @param instanceId Instance ID 135 | */ 136 | WebSocketFree: function(instanceId) 137 | { 138 | var instance = webSocketManager.instances[instanceId]; 139 | if (!instance) return 0; 140 | 141 | // Close if not closed 142 | if (instance.ws !== null && instance.ws.readyState < 2) 143 | instance.ws.close(); 144 | 145 | // Remove reference 146 | delete webSocketManager.instances[instanceId]; 147 | 148 | return 0; 149 | }, 150 | 151 | /** 152 | * Connect WebSocket to the server 153 | * 154 | * @param instanceId Instance ID 155 | */ 156 | WebSocketConnect: function(instanceId) 157 | { 158 | var instance = webSocketManager.instances[instanceId]; 159 | if (!instance) return -1; 160 | if (instance.ws !== null) return -2; 161 | 162 | if (instance.subProtocols != null) 163 | instance.ws = new WebSocket(instance.url, instance.subProtocols); 164 | else 165 | instance.ws = new WebSocket(instance.url); 166 | 167 | instance.ws.onopen = function() 168 | { 169 | if (webSocketManager.support6000) 170 | { 171 | {{{ makeDynCall('vi', 'webSocketManager.onOpen') }}}(instanceId); 172 | } 173 | else 174 | { 175 | Module.dynCall_vi(webSocketManager.onOpen, instanceId); 176 | } 177 | }; 178 | 179 | instance.ws.onmessage = function(ev) 180 | { 181 | if (ev.data instanceof ArrayBuffer) 182 | { 183 | var array = new Uint8Array(ev.data); 184 | var buffer = _malloc(array.length); 185 | writeArrayToMemory(array, buffer); 186 | try 187 | { 188 | if (webSocketManager.support6000) 189 | { 190 | {{{ makeDynCall('viii', 'webSocketManager.onMessage') }}}(instanceId, buffer, array.length); 191 | } 192 | else 193 | { 194 | Module.dynCall_viii(webSocketManager.onMessage, instanceId, buffer, array.length); 195 | } 196 | } 197 | finally 198 | { 199 | _free(buffer); 200 | } 201 | } 202 | else if (typeof ev.data == 'string') 203 | { 204 | var length = lengthBytesUTF8(ev.data) + 1; 205 | var buffer = _malloc(length); 206 | stringToUTF8(ev.data, buffer, length); 207 | try 208 | { 209 | if (webSocketManager.support6000) 210 | { 211 | {{{ makeDynCall('vii', 'webSocketManager.onMessageStr') }}}(instanceId, buffer); 212 | } 213 | else 214 | { 215 | Module.dynCall_vii(webSocketManager.onMessageStr, instanceId, buffer); 216 | } 217 | } 218 | finally 219 | { 220 | _free(buffer); 221 | } 222 | } 223 | else if (typeof Blob !== 'undefined' && ev.data instanceof Blob) 224 | { 225 | var reader = new FileReader(); 226 | reader.onload = function() 227 | { 228 | var array = new Uint8Array(reader.result); 229 | var buffer = _malloc(array.length); 230 | writeArrayToMemory(array, buffer); 231 | try 232 | { 233 | if (webSocketManager.support6000) 234 | { 235 | {{{ makeDynCall('viii', 'webSocketManager.onMessage') }}}(instanceId, buffer, array.length); 236 | } 237 | else 238 | { 239 | Module.dynCall_viii(webSocketManager.onMessage, instanceId, buffer, array.length); 240 | } 241 | } 242 | finally 243 | { 244 | reader = null; 245 | _free(buffer); 246 | } 247 | }; 248 | reader.readAsArrayBuffer(ev.data); 249 | } 250 | else 251 | { 252 | console.log("[JSLIB WebSocket] not support message type: ", (typeof ev.data)); 253 | } 254 | }; 255 | 256 | instance.ws.onerror = function(ev) 257 | { 258 | var msg = "WebSocket error."; 259 | var length = lengthBytesUTF8(msg) + 1; 260 | var buffer = _malloc(length); 261 | stringToUTF8(msg, buffer, length); 262 | try 263 | { 264 | if (webSocketManager.support6000) 265 | { 266 | {{{ makeDynCall('vii', 'webSocketManager.onError') }}}(instanceId, buffer); 267 | } 268 | else 269 | { 270 | Module.dynCall_vii(webSocketManager.onError, instanceId, buffer); 271 | } 272 | } 273 | finally 274 | { 275 | _free(buffer); 276 | } 277 | }; 278 | 279 | instance.ws.onclose = function(ev) 280 | { 281 | var msg = ev.reason; 282 | var length = lengthBytesUTF8(msg) + 1; 283 | var buffer = _malloc(length); 284 | stringToUTF8(msg, buffer, length); 285 | try 286 | { 287 | if (webSocketManager.support6000) 288 | { 289 | {{{ makeDynCall('viii', 'webSocketManager.onClose') }}}(instanceId, ev.code, buffer); 290 | } 291 | else 292 | { 293 | Module.dynCall_viii(webSocketManager.onClose, instanceId, ev.code, buffer); 294 | } 295 | } 296 | finally 297 | { 298 | _free(buffer); 299 | } 300 | instance.ws = null; 301 | }; 302 | 303 | return 0; 304 | }, 305 | 306 | /** 307 | * Close WebSocket connection 308 | * 309 | * @param instanceId Instance ID 310 | * @param code Close status code 311 | * @param reasonPtr Pointer to reason string 312 | */ 313 | WebSocketClose: function(instanceId, code, reasonPtr) 314 | { 315 | var instance = webSocketManager.instances[instanceId]; 316 | if (!instance) return -1; 317 | if (instance.ws === null) return -3; 318 | if (instance.ws.readyState === 2) return -4; 319 | if (instance.ws.readyState === 3) return -5; 320 | 321 | var reason = ( reasonPtr ? UTF8ToString(reasonPtr) : undefined ); 322 | try 323 | { 324 | instance.ws.close(code, reason); 325 | } 326 | catch (err) 327 | { 328 | return -7; 329 | } 330 | 331 | return 0; 332 | }, 333 | 334 | /** 335 | * Send message over WebSocket 336 | * 337 | * @param instanceId Instance ID 338 | * @param bufferPtr Pointer to the message buffer 339 | * @param length Length of the message in the buffer 340 | */ 341 | WebSocketSend: function(instanceId, bufferPtr, length) 342 | { 343 | var instance = webSocketManager.instances[instanceId]; 344 | if (!instance) return -1; 345 | if (instance.ws === null) return -3; 346 | if (instance.ws.readyState !== 1) return -6; 347 | 348 | if (typeof HEAPU8 !== 'undefined') 349 | instance.ws.send(HEAPU8.buffer.slice(bufferPtr, bufferPtr + length)); 350 | else if (typeof buffer !== 'undefined') 351 | instance.ws.send(buffer.slice(bufferPtr, bufferPtr + length)); 352 | else 353 | return -8; // not support buffer slice 354 | 355 | return 0; 356 | }, 357 | 358 | /** 359 | * Send message string over WebSocket 360 | * 361 | * @param instanceId Instance ID 362 | * @param stringPtr Pointer to the message string 363 | */ 364 | WebSocketSendStr: function(instanceId, stringPtr) 365 | { 366 | var instance = webSocketManager.instances[instanceId]; 367 | if (!instance) return -1; 368 | if (instance.ws === null) return -3; 369 | if (instance.ws.readyState !== 1) return -6; 370 | 371 | instance.ws.send(UTF8ToString(stringPtr)); 372 | 373 | return 0; 374 | }, 375 | 376 | /** 377 | * Return WebSocket readyState 378 | * 379 | * @param instanceId Instance ID 380 | */ 381 | WebSocketGetState: function(instanceId) 382 | { 383 | var instance = webSocketManager.instances[instanceId]; 384 | if (!instance) return -1; 385 | if (instance.ws === null) return 3; // socket null as closed 386 | 387 | return instance.ws.readyState; 388 | } 389 | }; 390 | 391 | autoAddDeps(WebSocketLibrary, '$webSocketManager'); 392 | mergeInto(LibraryManager.library, WebSocketLibrary); 393 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Plugins/WebGL/WebSocket.jslib.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd88770aa13fc47b08f87d2145e9ac6e 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Facebook: WebGL 27 | second: 28 | enabled: 1 29 | settings: {} 30 | - first: 31 | WebGL: WebGL 32 | second: 33 | enabled: 1 34 | settings: {} 35 | - first: 36 | WeixinMiniGame: WeixinMiniGame 37 | second: 38 | enabled: 1 39 | settings: {} 40 | userData: 41 | assetBundleName: 42 | assetBundleVariant: 43 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89cd0cf8603ef4069b2f6a5d79cbdbe1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb71bb4fb62590c4b975ef865b4df25f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Editor/SettingsWindow.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using UnityEngine.Networking; 4 | using System.IO; 5 | using System; 6 | 7 | namespace UnityWebSocket.Editor 8 | { 9 | internal class SettingsWindow : EditorWindow 10 | { 11 | static SettingsWindow window = null; 12 | [MenuItem("Tools/UnityWebSocket", priority = 100)] 13 | internal static void Open() 14 | { 15 | if (window != null) 16 | { 17 | window.Close(); 18 | } 19 | 20 | window = GetWindow(true, "UnityWebSocket"); 21 | window.minSize = window.maxSize = new Vector2(600, 310); 22 | window.Show(); 23 | window.BeginCheck(); 24 | } 25 | 26 | private void OnGUI() 27 | { 28 | DrawLogo(); 29 | DrawVersion(); 30 | DrawSeparator(80); 31 | DrawSeparator(186); 32 | DrawHelper(); 33 | DrawFooter(); 34 | } 35 | 36 | Texture2D logoTex = null; 37 | private void DrawLogo() 38 | { 39 | if (logoTex == null) 40 | { 41 | logoTex = new Texture2D(66, 66); 42 | logoTex.LoadImage(Convert.FromBase64String(LOGO_BASE64.VALUE)); 43 | for (int i = 0; i < 66; i++) for (int j = 0; j < 15; j++) logoTex.SetPixel(i, j, Color.clear); 44 | logoTex.Apply(); 45 | } 46 | 47 | var logoPos = new Rect(10, 10, 66, 66); 48 | GUI.DrawTexture(logoPos, logoTex); 49 | var title = "UnityWebSocket"; 50 | var titlePos = new Rect(80, 20, 500, 50); 51 | GUI.Label(titlePos, title, TextStyle(24)); 52 | } 53 | 54 | private void DrawSeparator(int y) 55 | { 56 | EditorGUI.DrawRect(new Rect(10, y, 580, 1), Color.white * 0.5f); 57 | } 58 | 59 | private GUIStyle TextStyle(int fontSize = 10, TextAnchor alignment = TextAnchor.UpperLeft, float alpha = 0.85f) 60 | { 61 | var style = new GUIStyle(); 62 | style.fontSize = fontSize; 63 | style.normal.textColor = (EditorGUIUtility.isProSkin ? Color.white : Color.black) * alpha; 64 | style.alignment = alignment; 65 | style.richText = true; 66 | return style; 67 | } 68 | 69 | private void DrawVersion() 70 | { 71 | GUI.Label(new Rect(440, 10, 150, 10), "Current Version: " + Settings.VERSION, TextStyle(alignment: TextAnchor.MiddleLeft)); 72 | if (string.IsNullOrEmpty(latestVersion)) 73 | { 74 | GUI.Label(new Rect(440, 30, 150, 10), "Checking for Updates...", TextStyle(alignment: TextAnchor.MiddleLeft)); 75 | } 76 | else if (latestVersion == "unknown") 77 | { 78 | 79 | } 80 | else 81 | { 82 | GUI.Label(new Rect(440, 30, 150, 10), "Latest Version: " + latestVersion, TextStyle(alignment: TextAnchor.MiddleLeft)); 83 | if (Settings.VERSION == latestVersion) 84 | { 85 | if (GUI.Button(new Rect(440, 50, 150, 18), "Check Update")) 86 | { 87 | latestVersion = ""; 88 | changeLog = ""; 89 | BeginCheck(); 90 | } 91 | } 92 | else 93 | { 94 | if (GUI.Button(new Rect(440, 50, 150, 18), "Update to | " + latestVersion)) 95 | { 96 | Application.OpenURL(Settings.GITHUB + "/releases"); 97 | } 98 | } 99 | } 100 | } 101 | 102 | private void DrawHelper() 103 | { 104 | GUI.Label(new Rect(330, 200, 100, 18), "GitHub:", TextStyle(10, TextAnchor.MiddleRight)); 105 | if (GUI.Button(new Rect(440, 200, 150, 18), "UnityWebSocket")) 106 | { 107 | Application.OpenURL(Settings.GITHUB); 108 | } 109 | 110 | GUI.Label(new Rect(330, 225, 100, 18), "Report:", TextStyle(10, TextAnchor.MiddleRight)); 111 | if (GUI.Button(new Rect(440, 225, 150, 18), "Report an Issue")) 112 | { 113 | Application.OpenURL(Settings.GITHUB + "/issues/new"); 114 | } 115 | 116 | GUI.Label(new Rect(330, 250, 100, 18), "Email:", TextStyle(10, TextAnchor.MiddleRight)); 117 | if (GUI.Button(new Rect(440, 250, 150, 18), Settings.EMAIL)) 118 | { 119 | var uri = new Uri(string.Format("mailto:{0}?subject={1}", Settings.EMAIL, "UnityWebSocket Feedback")); 120 | Application.OpenURL(uri.AbsoluteUri); 121 | } 122 | 123 | GUI.Label(new Rect(330, 275, 100, 18), "QQ Group:", TextStyle(10, TextAnchor.MiddleRight)); 124 | if (GUI.Button(new Rect(440, 275, 150, 18), Settings.QQ_GROUP)) 125 | { 126 | Application.OpenURL(Settings.QQ_GROUP_LINK); 127 | } 128 | } 129 | 130 | private void DrawFooter() 131 | { 132 | EditorGUI.DropShadowLabel(new Rect(10, 230, 400, 20), "Developed by " + Settings.AUHTOR); 133 | EditorGUI.DropShadowLabel(new Rect(10, 250, 400, 20), "All rights reserved"); 134 | } 135 | 136 | UnityWebRequest req; 137 | string changeLog = ""; 138 | string latestVersion = ""; 139 | void BeginCheck() 140 | { 141 | EditorApplication.update -= VersionCheckUpdate; 142 | EditorApplication.update += VersionCheckUpdate; 143 | 144 | req = UnityWebRequest.Get(Settings.GITHUB + "/releases/latest"); 145 | req.SendWebRequest(); 146 | } 147 | 148 | private void VersionCheckUpdate() 149 | { 150 | #if UNITY_2020_3_OR_NEWER 151 | if (req == null 152 | || req.result == UnityWebRequest.Result.ConnectionError 153 | || req.result == UnityWebRequest.Result.DataProcessingError 154 | || req.result == UnityWebRequest.Result.ProtocolError) 155 | #elif UNITY_2018_1_OR_NEWER 156 | if (req == null || req.isNetworkError || req.isHttpError) 157 | #else 158 | if (req == null || req.isError) 159 | #endif 160 | { 161 | EditorApplication.update -= VersionCheckUpdate; 162 | latestVersion = "unknown"; 163 | return; 164 | } 165 | 166 | if (req.isDone) 167 | { 168 | EditorApplication.update -= VersionCheckUpdate; 169 | latestVersion = req.url.Substring(req.url.LastIndexOf("/") + 1).TrimStart('v'); 170 | 171 | if (Settings.VERSION != latestVersion) 172 | { 173 | var text = req.downloadHandler.text; 174 | var st = text.IndexOf("content=\"" + latestVersion); 175 | st = st > 0 ? text.IndexOf("\n", st) : -1; 176 | var end = st > 0 ? text.IndexOf("\" />", st) : -1; 177 | if (st > 0 && end > st) 178 | { 179 | changeLog = text.Substring(st + 1, end - st - 1).Trim(); 180 | changeLog = changeLog.Replace("\r", ""); 181 | changeLog = changeLog.Replace("\n", "\n- "); 182 | changeLog = "\nCHANGE LOG: \n- " + changeLog + "\n"; 183 | } 184 | } 185 | 186 | Repaint(); 187 | } 188 | } 189 | } 190 | 191 | internal static class LOGO_BASE64 192 | { 193 | internal const string VALUE = "iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAMAAADUivDaAAAAq1BMVEUAAABKmtcvjtYzl" + 194 | "9szmNszl9syl9k0mNs0mNwzmNs0mNszl9szl9s0mNs0mNwzmNw0mNwyltk0mNw0mNwzl9s0mNsymNs0mNszmNwzmNwzm" + 195 | "NszmNs0mNwzl9w0mNwzmNw0mNs0mNs0mNwzl9wzmNs0mNwzmNs0mNwzl90zmNszmNszl9szmNsxmNszmNszmNw0mNwzm" + 196 | "Nw0mNs2neM4pe41mt43ouo2oOY5qfM+UHlaAAAAMnRSTlMAAwXN3sgI+/069MSCK6M/MA74h9qfFHB8STWMJ9OSdmNcI" + 197 | "8qya1IeF+/U0EIa57mqmFTYJe4AAAN3SURBVFjD7ZbpkppAFEa/bgVBREF2kEVGFNeZsM77P1kadURnJkr8k1Qlx1Khu" + 198 | "/pw7+2lwH/+YcgfMBBLG7VocwDamzH+wJBB8Qhjve2f0TdrGwjei6o4Ub/nM/APw5Z7vvSB/qrCrqbD6fBEVtigeMxks" + 199 | "fX9zWbj+z1jhqgSBplQ50eGo4614WXlRAzgrRhmtSfvxAn7pB0N5ObaKKZZuU5/d37IBcBgUQwqDuf7Z2gUmVAl4NGNr" + 200 | "/UeHxV5n39ulbaKLI86h6HilmM5M1aN126lpNhtl59yeTsp8nUMvpNC1J3bh5FtfVRk+bJrJunn5d4U4piJ/Vw9eXgsj" + 201 | "4ZpZaCjg9waZkIpnBWLJ44OwoNu60F2UnSaEkKv4XnAlCpm6B4F/aKMDiyGi2L8SEEAVdxNLuzmgV7nFwObEe2xQVuX+" + 202 | "RV1lWetga3w+cN1sXgvm4cJH8OEgZC1DPKhfF/BIymmQrMjq/x65FUeEkDup8GxoexZmznHCvANtXU/CAq13yimhQGtm" + 203 | "H4VCPnBBL1fTKo3CqEcvq7Lb/OwHxWTYlyw+JmjKoVvDLVOQB4pVsM8K8smgvLCxZDlIijwyOEc+nr/msMwK0+GQWGBd" + 204 | "tmhjv8icTds1s2ammaFh04QLLe69NK7guP6mTDMaw3o6nAX/Z7EXUskPSvWEWg4srVlp5NTDXv9Lce9HGN5eeG4nj5Yz" + 205 | "ACteU2wQLo4MBtJfd1nw5nG1/s9zwUQ6pykL1TQjqdeuvQW0naz2XKLYL4Cwzr4vj+OQdD96CSp7Lrynp4aeFF0xdm5q" + 206 | "6OFtFfPv7URxpWJNjd/N+3+I9+1klMav12Qtgbt9R2JaIopjkzaPtOFq4KxUpqfUMSFnQrySWjLoQzRZS4HMH84ME1ej" + 207 | "S1YJpQZ3B+sR1uCQJSBdGdCk1eAEgORR88KK05W8dh2MA+A/SKCYu3mCJ0Ek7HBx4HHeuwYy5G3x8hSMTJcOMFbinCsn" + 208 | "hO1V1aszGULvA0g4UFsb4VA0hAFcyo6cgLsAoT7uUtGAH5wQKQle0wuLyxLTaNyJEYwxw4wSljLK1TP8CAaOyhBMMEsj" + 209 | "OBoXgo7VGElFkSWL+vef1RF2YNXeRWYzQBTpkhC8KaZHhuIogArkQLKClBZjU26B2IZgGz+cpZkHl8g3fYUaW/YP2kb2" + 210 | "M/V97JY/vZN859n+QmO7XtC9Bf2jAAAAABJRU5ErkJggg=="; 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Editor/SettingsWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7c42d421cc4c34f3eae1fbd67f0dced0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Editor/UnityWebSocket.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UnityWebSocket.Editor", 3 | "references": [ 4 | "UnityWebSocket.Runtime" 5 | ], 6 | "optionalUnityReferences": [], 7 | "includePlatforms": [ 8 | "Editor" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": false, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [] 16 | } -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Editor/UnityWebSocket.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee833745c57bd4369ab8f0ff380a96fa 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 53e0ed9fdc3af42eba12a5b1b9a5f873 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b3a2a8f55d4a47f599b1fa3ed612389 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/CloseEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWebSocket 4 | { 5 | /// 6 | /// Represents the event data for the event. 7 | /// 8 | /// 9 | /// 10 | /// That event occurs when the WebSocket connection has been closed. 11 | /// 12 | /// 13 | /// If you would like to get the reason for the close, you should access 14 | /// the or property. 15 | /// 16 | /// 17 | public class CloseEventArgs : EventArgs 18 | { 19 | #region Internal Constructors 20 | 21 | internal CloseEventArgs() 22 | { 23 | } 24 | 25 | internal CloseEventArgs(ushort code) 26 | : this(code, null) 27 | { 28 | } 29 | 30 | internal CloseEventArgs(CloseStatusCode code) 31 | : this((ushort)code, null) 32 | { 33 | } 34 | 35 | internal CloseEventArgs(CloseStatusCode code, string reason) 36 | : this((ushort)code, reason) 37 | { 38 | } 39 | 40 | internal CloseEventArgs(ushort code, string reason) 41 | { 42 | Code = code; 43 | Reason = reason; 44 | } 45 | 46 | #endregion 47 | 48 | #region Public Properties 49 | 50 | /// 51 | /// Gets the status code for the close. 52 | /// 53 | /// 54 | /// A that represents the status code for the close if any. 55 | /// 56 | public ushort Code { get; private set; } 57 | 58 | /// 59 | /// Gets the reason for the close. 60 | /// 61 | /// 62 | /// A that represents the reason for the close if any. 63 | /// 64 | public string Reason { get; private set; } 65 | 66 | /// 67 | /// Gets a value indicating whether the connection has been closed cleanly. 68 | /// 69 | /// 70 | /// true if the connection has been closed cleanly; otherwise, false. 71 | /// 72 | public bool WasClean { get; internal set; } 73 | 74 | /// 75 | /// Enum value same as Code 76 | /// 77 | public CloseStatusCode StatusCode 78 | { 79 | get 80 | { 81 | if (Enum.IsDefined(typeof(CloseStatusCode), Code)) 82 | return (CloseStatusCode)Code; 83 | return CloseStatusCode.Unknown; 84 | } 85 | } 86 | 87 | #endregion 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/CloseEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29b987d07ba15434cb1744135a7a5416 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/CloseStatusCode.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWebSocket 2 | { 3 | /// 4 | /// Indicates the status code for the WebSocket connection close. 5 | /// 6 | /// 7 | /// 8 | /// The values of this enumeration are defined in 9 | /// 10 | /// Section 7.4 of RFC 6455. 11 | /// 12 | /// 13 | /// "Reserved value" cannot be sent as a status code in 14 | /// closing handshake by an endpoint. 15 | /// 16 | /// 17 | public enum CloseStatusCode : ushort 18 | { 19 | Unknown = 65534, 20 | /// 21 | /// Equivalent to close status 1000. Indicates normal close. 22 | /// 23 | Normal = 1000, 24 | /// 25 | /// Equivalent to close status 1001. Indicates that an endpoint is 26 | /// going away. 27 | /// 28 | Away = 1001, 29 | /// 30 | /// Equivalent to close status 1002. Indicates that an endpoint is 31 | /// terminating the connection due to a protocol error. 32 | /// 33 | ProtocolError = 1002, 34 | /// 35 | /// Equivalent to close status 1003. Indicates that an endpoint is 36 | /// terminating the connection because it has received a type of 37 | /// data that it cannot accept. 38 | /// 39 | UnsupportedData = 1003, 40 | /// 41 | /// Equivalent to close status 1004. Still undefined. A Reserved value. 42 | /// 43 | Undefined = 1004, 44 | /// 45 | /// Equivalent to close status 1005. Indicates that no status code was 46 | /// actually present. A Reserved value. 47 | /// 48 | NoStatus = 1005, 49 | /// 50 | /// Equivalent to close status 1006. Indicates that the connection was 51 | /// closed abnormally. A Reserved value. 52 | /// 53 | Abnormal = 1006, 54 | /// 55 | /// Equivalent to close status 1007. Indicates that an endpoint is 56 | /// terminating the connection because it has received a message that 57 | /// contains data that is not consistent with the type of the message. 58 | /// 59 | InvalidData = 1007, 60 | /// 61 | /// Equivalent to close status 1008. Indicates that an endpoint is 62 | /// terminating the connection because it has received a message that 63 | /// violates its policy. 64 | /// 65 | PolicyViolation = 1008, 66 | /// 67 | /// Equivalent to close status 1009. Indicates that an endpoint is 68 | /// terminating the connection because it has received a message that 69 | /// is too big to process. 70 | /// 71 | TooBig = 1009, 72 | /// 73 | /// Equivalent to close status 1010. Indicates that a client is 74 | /// terminating the connection because it has expected the server to 75 | /// negotiate one or more extension, but the server did not return 76 | /// them in the handshake response. 77 | /// 78 | MandatoryExtension = 1010, 79 | /// 80 | /// Equivalent to close status 1011. Indicates that a server is 81 | /// terminating the connection because it has encountered an unexpected 82 | /// condition that prevented it from fulfilling the request. 83 | /// 84 | ServerError = 1011, 85 | /// 86 | /// Equivalent to close status 1015. Indicates that the connection was 87 | /// closed due to a failure to perform a TLS handshake. A Reserved value. 88 | /// 89 | TlsHandshakeFailure = 1015, 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/CloseStatusCode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e34ee317292e4225a10427cc35f85ec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/ErrorEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWebSocket 4 | { 5 | /// 6 | /// Represents the event data for the event. 7 | /// 8 | /// 9 | /// 10 | /// That event occurs when the gets an error. 11 | /// 12 | /// 13 | /// If you would like to get the error message, you should access 14 | /// the property. 15 | /// 16 | /// 17 | /// And if the error is due to an exception, you can get it by accessing 18 | /// the property. 19 | /// 20 | /// 21 | public class ErrorEventArgs : EventArgs 22 | { 23 | #region Internal Constructors 24 | 25 | internal ErrorEventArgs(string message) 26 | : this(message, null) 27 | { 28 | } 29 | 30 | internal ErrorEventArgs(string message, Exception exception) 31 | { 32 | this.Message = message; 33 | this.Exception = exception; 34 | } 35 | 36 | #endregion 37 | 38 | #region Public Properties 39 | 40 | /// 41 | /// Gets the exception that caused the error. 42 | /// 43 | /// 44 | /// An instance that represents the cause of 45 | /// the error if it is due to an exception; otherwise, . 46 | /// 47 | public Exception Exception { get; private set; } 48 | 49 | /// 50 | /// Gets the error message. 51 | /// 52 | /// 53 | /// A that represents the error message. 54 | /// 55 | public string Message { get; private set; } 56 | 57 | #endregion 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/ErrorEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 884e7db60b6444154b7200e0e436f2de 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWebSocket 4 | { 5 | /// 6 | /// IWebSocket indicate a network connection. 7 | /// It can be connecting, connected, closing or closed state. 8 | /// You can send and receive messages by using it. 9 | /// Register callbacks for handling messages. 10 | /// ----------------------------------------------------------- 11 | /// IWebSocket 表示一个网络连接, 12 | /// 它可以是 connecting connected closing closed 状态, 13 | /// 可以发送和接收消息, 14 | /// 通过注册消息回调,来处理接收到的消息。 15 | /// 16 | public interface IWebSocket 17 | { 18 | /// 19 | /// Establishes a connection asynchronously. 20 | /// 21 | /// 22 | /// 23 | /// This method does not wait for the connect process to be complete. 24 | /// 25 | /// 26 | /// This method does nothing if the connection has already been 27 | /// established. 28 | /// 29 | /// 30 | /// 31 | /// 32 | /// This instance is not a client. 33 | /// 34 | /// 35 | /// -or- 36 | /// 37 | /// 38 | /// The close process is in progress. 39 | /// 40 | /// 41 | /// -or- 42 | /// 43 | /// 44 | /// A series of reconnecting has failed. 45 | /// 46 | /// 47 | void ConnectAsync(); 48 | 49 | /// 50 | /// Closes the connection asynchronously. 51 | /// 52 | /// 53 | /// 54 | /// This method does not wait for the close to be complete. 55 | /// 56 | /// 57 | /// This method does nothing if the current state of the connection is 58 | /// Closing or Closed. 59 | /// 60 | /// 61 | void CloseAsync(); 62 | 63 | /// 64 | /// Sends the specified data asynchronously using the WebSocket connection. 65 | /// 66 | /// 67 | /// This method does not wait for the send to be complete. 68 | /// 69 | /// 70 | /// An array of that represents the binary data to send. 71 | /// 72 | /// 73 | /// The current state of the connection is not Open. 74 | /// 75 | /// 76 | /// is . 77 | /// 78 | void SendAsync(byte[] data); 79 | 80 | /// 81 | /// Sends the specified data using the WebSocket connection. 82 | /// 83 | /// 84 | /// A that represents the text data to send. 85 | /// 86 | /// 87 | /// The current state of the connection is not Open. 88 | /// 89 | /// 90 | /// is . 91 | /// 92 | /// 93 | /// could not be UTF-8 encoded. 94 | /// 95 | void SendAsync(string text); 96 | 97 | /// 98 | /// get the address which to connect. 99 | /// 100 | string Address { get; } 101 | 102 | /// 103 | /// get sub protocols . 104 | /// 105 | string[] SubProtocols { get; } 106 | 107 | /// 108 | /// Gets the current state of the connection. 109 | /// 110 | /// 111 | /// 112 | /// One of the enum values. 113 | /// 114 | /// 115 | /// It indicates the current state of the connection. 116 | /// 117 | /// 118 | /// The default value is . 119 | /// 120 | /// 121 | WebSocketState ReadyState { get; } 122 | 123 | /// 124 | /// Occurs when the WebSocket connection has been established. 125 | /// 126 | event EventHandler OnOpen; 127 | 128 | /// 129 | /// Occurs when the WebSocket connection has been closed. 130 | /// 131 | event EventHandler OnClose; 132 | 133 | /// 134 | /// Occurs when the gets an error. 135 | /// 136 | event EventHandler OnError; 137 | 138 | /// 139 | /// Occurs when the receives a message. 140 | /// 141 | event EventHandler OnMessage; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/IWebSocket.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37ee2146eb8c34ffab8b081a632b05cf 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | 4 | namespace UnityWebSocket 5 | { 6 | public class MessageEventArgs : EventArgs 7 | { 8 | private byte[] _rawData; 9 | private string _data; 10 | 11 | internal MessageEventArgs(Opcode opcode, byte[] rawData) 12 | { 13 | Opcode = opcode; 14 | _rawData = rawData; 15 | } 16 | 17 | internal MessageEventArgs(Opcode opcode, string data) 18 | { 19 | Opcode = opcode; 20 | _data = data; 21 | } 22 | 23 | /// 24 | /// Gets the opcode for the message. 25 | /// 26 | /// 27 | /// , . 28 | /// 29 | internal Opcode Opcode { get; private set; } 30 | 31 | /// 32 | /// Gets the message data as a . 33 | /// 34 | /// 35 | /// A that represents the message data if its type is 36 | /// text and if decoding it to a string has successfully done; 37 | /// otherwise, . 38 | /// 39 | public string Data 40 | { 41 | get 42 | { 43 | SetData(); 44 | return _data; 45 | } 46 | } 47 | 48 | /// 49 | /// Gets the message data as an array of . 50 | /// 51 | /// 52 | /// An array of that represents the message data. 53 | /// 54 | public byte[] RawData 55 | { 56 | get 57 | { 58 | SetRawData(); 59 | return _rawData; 60 | } 61 | } 62 | 63 | /// 64 | /// Gets a value indicating whether the message type is binary. 65 | /// 66 | /// 67 | /// true if the message type is binary; otherwise, false. 68 | /// 69 | public bool IsBinary 70 | { 71 | get 72 | { 73 | return Opcode == Opcode.Binary; 74 | } 75 | } 76 | 77 | /// 78 | /// Gets a value indicating whether the message type is text. 79 | /// 80 | /// 81 | /// true if the message type is text; otherwise, false. 82 | /// 83 | public bool IsText 84 | { 85 | get 86 | { 87 | return Opcode == Opcode.Text; 88 | } 89 | } 90 | 91 | private void SetData() 92 | { 93 | if (_data != null) return; 94 | 95 | if (RawData == null) 96 | { 97 | return; 98 | } 99 | 100 | _data = Encoding.UTF8.GetString(RawData); 101 | } 102 | 103 | private void SetRawData() 104 | { 105 | if (_rawData != null) return; 106 | 107 | if (_data == null) 108 | { 109 | return; 110 | } 111 | 112 | _rawData = Encoding.UTF8.GetBytes(_data); 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/MessageEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b44eda173b4924081bab76ae9d1b0a9c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/Opcode.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWebSocket 2 | { 3 | /// 4 | /// Indicates the WebSocket frame type. 5 | /// 6 | /// 7 | /// The values of this enumeration are defined in 8 | /// 9 | /// Section 5.2 of RFC 6455. 10 | /// 11 | public enum Opcode : byte 12 | { 13 | /// 14 | /// Equivalent to numeric value 1. Indicates text frame. 15 | /// 16 | Text = 0x1, 17 | /// 18 | /// Equivalent to numeric value 2. Indicates binary frame. 19 | /// 20 | Binary = 0x2, 21 | /// 22 | /// Equivalent to numeric value 8. Indicates connection close frame. 23 | /// 24 | Close = 0x8, 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/Opcode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eeac0ef90273544ebbae046672caf362 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/OpenEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace UnityWebSocket 4 | { 5 | public class OpenEventArgs : EventArgs 6 | { 7 | internal OpenEventArgs() 8 | { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/OpenEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fb6fd704bd4e4b8ba63cd0b28712955 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWebSocket 2 | { 3 | public static class Settings 4 | { 5 | public const string GITHUB = "https://github.com/psygames/UnityWebSocket"; 6 | public const string QQ_GROUP = "1126457634"; 7 | public const string QQ_GROUP_LINK = "https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd"; 8 | public const string EMAIL = "799329256@qq.com"; 9 | public const string AUHTOR = "psygames"; 10 | public const string VERSION = "2.8.6"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/Settings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e268303c7a605e343b1b132e5559f01f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/WebSocketState.cs: -------------------------------------------------------------------------------- 1 | namespace UnityWebSocket 2 | { 3 | /// 4 | /// Reference html5 WebSocket ReadyState Properties 5 | /// Indicates the state of a WebSocket connection. 6 | /// 7 | /// 8 | /// The values of this enumeration are defined in 9 | /// 10 | /// The WebSocket API. 11 | /// 12 | public enum WebSocketState : ushort 13 | { 14 | /// 15 | /// Equivalent to numeric value 0. Indicates that the connection has not 16 | /// yet been established. 17 | /// 18 | Connecting = 0, 19 | /// 20 | /// Equivalent to numeric value 1. Indicates that the connection has 21 | /// been established, and the communication is possible. 22 | /// 23 | Open = 1, 24 | /// 25 | /// Equivalent to numeric value 2. Indicates that the connection is 26 | /// going through the closing handshake, or the close method has 27 | /// been invoked. 28 | /// 29 | Closing = 2, 30 | /// 31 | /// Equivalent to numeric value 3. Indicates that the connection has 32 | /// been closed or could not be established. 33 | /// 34 | Closed = 3 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Core/WebSocketState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5f6567ad13cb147a59f8af784f1c5f60 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 396c66b333d624d539153070900bb73b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c110a898ae8b0b41bcf4da49c2b0425 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs: -------------------------------------------------------------------------------- 1 | #if !NET_LEGACY && (UNITY_EDITOR || !UNITY_WEBGL) 2 | using System; 3 | using System.Text; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Net.WebSockets; 7 | using System.IO; 8 | using System.Collections.Concurrent; 9 | 10 | namespace UnityWebSocket 11 | { 12 | public class WebSocket : IWebSocket 13 | { 14 | public string Address { get; private set; } 15 | public string[] SubProtocols { get; private set; } 16 | 17 | public WebSocketState ReadyState 18 | { 19 | get 20 | { 21 | if (socket == null) 22 | return WebSocketState.Closed; 23 | switch (socket.State) 24 | { 25 | case System.Net.WebSockets.WebSocketState.Closed: 26 | case System.Net.WebSockets.WebSocketState.None: 27 | return WebSocketState.Closed; 28 | case System.Net.WebSockets.WebSocketState.CloseReceived: 29 | case System.Net.WebSockets.WebSocketState.CloseSent: 30 | return WebSocketState.Closing; 31 | case System.Net.WebSockets.WebSocketState.Connecting: 32 | return WebSocketState.Connecting; 33 | case System.Net.WebSockets.WebSocketState.Open: 34 | return WebSocketState.Open; 35 | } 36 | return WebSocketState.Closed; 37 | } 38 | } 39 | 40 | public event EventHandler OnOpen; 41 | public event EventHandler OnClose; 42 | public event EventHandler OnError; 43 | public event EventHandler OnMessage; 44 | 45 | private ClientWebSocket socket; 46 | private bool isOpening => socket != null && socket.State == System.Net.WebSockets.WebSocketState.Open; 47 | private ConcurrentQueue sendQueue = new ConcurrentQueue(); 48 | private ConcurrentQueue eventQueue = new ConcurrentQueue(); 49 | private bool closeProcessing; 50 | private CancellationTokenSource cts = null; 51 | 52 | #region APIs 53 | public WebSocket(string address) 54 | { 55 | this.Address = address; 56 | } 57 | 58 | public WebSocket(string address, string subProtocol) 59 | { 60 | this.Address = address; 61 | this.SubProtocols = new string[] { subProtocol }; 62 | } 63 | 64 | public WebSocket(string address, string[] subProtocols) 65 | { 66 | this.Address = address; 67 | this.SubProtocols = subProtocols; 68 | } 69 | 70 | public void ConnectAsync() 71 | { 72 | if (socket != null) 73 | { 74 | HandleError(new Exception("Socket is busy.")); 75 | return; 76 | } 77 | 78 | WebSocketManager.Instance.Add(this); 79 | 80 | socket = new ClientWebSocket(); 81 | cts = new CancellationTokenSource(); 82 | 83 | // support sub protocols 84 | if (this.SubProtocols != null) 85 | { 86 | foreach (var protocol in this.SubProtocols) 87 | { 88 | if (string.IsNullOrEmpty(protocol)) continue; 89 | Log($"Add Sub Protocol {protocol}"); 90 | socket.Options.AddSubProtocol(protocol); 91 | } 92 | } 93 | 94 | Task.Run(ConnectTask); 95 | } 96 | 97 | public void CloseAsync() 98 | { 99 | if (!isOpening) return; 100 | closeProcessing = true; 101 | } 102 | 103 | public void SendAsync(byte[] data) 104 | { 105 | if (!isOpening) return; 106 | var buffer = new SendBuffer(data, WebSocketMessageType.Binary); 107 | sendQueue.Enqueue(buffer); 108 | } 109 | 110 | public void SendAsync(string text) 111 | { 112 | if (!isOpening) return; 113 | var data = Encoding.UTF8.GetBytes(text); 114 | var buffer = new SendBuffer(data, WebSocketMessageType.Text); 115 | sendQueue.Enqueue(buffer); 116 | } 117 | #endregion 118 | 119 | class SendBuffer 120 | { 121 | public byte[] data; 122 | public WebSocketMessageType type; 123 | public SendBuffer(byte[] data, WebSocketMessageType type) 124 | { 125 | this.data = data; 126 | this.type = type; 127 | } 128 | } 129 | 130 | private void CleanSendQueue() 131 | { 132 | while (sendQueue.TryDequeue(out var _)) ; 133 | } 134 | 135 | private void CleanEventQueue() 136 | { 137 | while (eventQueue.TryDequeue(out var _)) ; 138 | } 139 | 140 | private async Task ConnectTask() 141 | { 142 | Log("Connect Task Begin ..."); 143 | 144 | try 145 | { 146 | var uri = new Uri(Address); 147 | await socket.ConnectAsync(uri, cts.Token); 148 | } 149 | catch (Exception e) 150 | { 151 | HandleError(e); 152 | HandleClose((ushort)CloseStatusCode.Abnormal, e.Message); 153 | return; 154 | } 155 | 156 | HandleOpen(); 157 | 158 | Log("Connect Task Success !"); 159 | 160 | StartReceiveTask(); 161 | StartSendTask(); 162 | } 163 | 164 | private async void StartSendTask() 165 | { 166 | Log("Send Task Begin ..."); 167 | 168 | try 169 | { 170 | while (!closeProcessing && socket != null && cts != null && !cts.IsCancellationRequested) 171 | { 172 | while (!closeProcessing && sendQueue.Count > 0 && sendQueue.TryDequeue(out var buffer)) 173 | { 174 | Log($"Send, type: {buffer.type}, size: {buffer.data.Length}, queue left: {sendQueue.Count}"); 175 | await socket.SendAsync(new ArraySegment(buffer.data), buffer.type, true, cts.Token); 176 | } 177 | Thread.Sleep(3); 178 | } 179 | if (closeProcessing && socket != null && cts != null && !cts.IsCancellationRequested) 180 | { 181 | CleanSendQueue(); 182 | Log($"Close Send Begin ..."); 183 | await socket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, "Normal Closure", cts.Token); 184 | Log($"Close Send Success !"); 185 | } 186 | } 187 | catch (Exception e) 188 | { 189 | HandleError(e); 190 | } 191 | finally 192 | { 193 | closeProcessing = false; 194 | } 195 | 196 | Log("Send Task End !"); 197 | } 198 | 199 | private async void StartReceiveTask() 200 | { 201 | Log("Receive Task Begin ..."); 202 | 203 | string closeReason = ""; 204 | ushort closeCode = 0; 205 | bool isClosed = false; 206 | var segment = new ArraySegment(new byte[8192]); 207 | var ms = new MemoryStream(); 208 | 209 | try 210 | { 211 | while (!isClosed && !cts.IsCancellationRequested) 212 | { 213 | var result = await socket.ReceiveAsync(segment, cts.Token); 214 | ms.Write(segment.Array, 0, result.Count); 215 | if (!result.EndOfMessage) continue; 216 | var data = ms.ToArray(); 217 | ms.SetLength(0); 218 | switch (result.MessageType) 219 | { 220 | case WebSocketMessageType.Binary: 221 | HandleMessage(Opcode.Binary, data); 222 | break; 223 | case WebSocketMessageType.Text: 224 | HandleMessage(Opcode.Text, data); 225 | break; 226 | case WebSocketMessageType.Close: 227 | isClosed = true; 228 | closeCode = (ushort)result.CloseStatus; 229 | closeReason = result.CloseStatusDescription; 230 | break; 231 | } 232 | } 233 | } 234 | catch (Exception e) 235 | { 236 | HandleError(e); 237 | closeCode = (ushort)CloseStatusCode.Abnormal; 238 | closeReason = e.Message; 239 | } 240 | finally 241 | { 242 | ms.Close(); 243 | } 244 | 245 | HandleClose(closeCode, closeReason); 246 | 247 | Log("Receive Task End !"); 248 | } 249 | 250 | private void SocketDispose() 251 | { 252 | Log("Dispose"); 253 | WebSocketManager.Instance.Remove(this); 254 | CleanSendQueue(); 255 | CleanEventQueue(); 256 | socket.Dispose(); 257 | socket = null; 258 | cts.Dispose(); 259 | cts = null; 260 | } 261 | 262 | private void HandleOpen() 263 | { 264 | Log("OnOpen"); 265 | eventQueue.Enqueue(new OpenEventArgs()); 266 | } 267 | 268 | private void HandleMessage(Opcode opcode, byte[] rawData) 269 | { 270 | Log($"OnMessage, type: {opcode}, size: {rawData.Length}"); 271 | eventQueue.Enqueue(new MessageEventArgs(opcode, rawData)); 272 | } 273 | 274 | private void HandleClose(ushort code, string reason) 275 | { 276 | Log($"OnClose, code: {code}, reason: {reason}"); 277 | eventQueue.Enqueue(new CloseEventArgs(code, reason)); 278 | } 279 | 280 | private void HandleError(Exception exception) 281 | { 282 | Log("OnError, error: " + exception.Message); 283 | eventQueue.Enqueue(new ErrorEventArgs(exception.Message)); 284 | } 285 | 286 | internal void Update() 287 | { 288 | while (eventQueue.Count > 0 && eventQueue.TryDequeue(out var e)) 289 | { 290 | if (e is CloseEventArgs) 291 | { 292 | OnClose?.Invoke(this, e as CloseEventArgs); 293 | SocketDispose(); 294 | break; 295 | } 296 | else if (e is OpenEventArgs) 297 | { 298 | OnOpen?.Invoke(this, e as OpenEventArgs); 299 | } 300 | else if (e is MessageEventArgs) 301 | { 302 | OnMessage?.Invoke(this, e as MessageEventArgs); 303 | } 304 | else if (e is ErrorEventArgs) 305 | { 306 | OnError?.Invoke(this, e as ErrorEventArgs); 307 | } 308 | } 309 | } 310 | 311 | internal void Abort() 312 | { 313 | Log("Abort"); 314 | if (cts != null) 315 | { 316 | cts.Cancel(); 317 | } 318 | } 319 | 320 | [System.Diagnostics.Conditional("UNITY_WEB_SOCKET_LOG")] 321 | static void Log(string msg) 322 | { 323 | var time = DateTime.Now.ToString("HH:mm:ss.fff"); 324 | var thread = Thread.CurrentThread.ManagedThreadId; 325 | UnityEngine.Debug.Log($"[{time}][UnityWebSocket][T-{thread:D3}] {msg}"); 326 | } 327 | } 328 | } 329 | #endif 330 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocket.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d10f88a23641b4beb8df74460fb7f705 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocketManager.cs: -------------------------------------------------------------------------------- 1 | #if !NET_LEGACY && (UNITY_EDITOR || !UNITY_WEBGL) 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityWebSocket 6 | { 7 | [DisallowMultipleComponent] 8 | [DefaultExecutionOrder(-10000)] 9 | internal class WebSocketManager : MonoBehaviour 10 | { 11 | private const string rootName = "[UnityWebSocket]"; 12 | private static WebSocketManager _instance; 13 | public static WebSocketManager Instance 14 | { 15 | get 16 | { 17 | if (!_instance) CreateInstance(); 18 | return _instance; 19 | } 20 | } 21 | 22 | private void Awake() 23 | { 24 | DontDestroyOnLoad(gameObject); 25 | } 26 | 27 | public static void CreateInstance() 28 | { 29 | GameObject go = GameObject.Find("/" + rootName); 30 | if (!go) go = new GameObject(rootName); 31 | _instance = go.GetComponent(); 32 | if (!_instance) _instance = go.AddComponent(); 33 | } 34 | 35 | private readonly List sockets = new List(); 36 | 37 | public void Add(WebSocket socket) 38 | { 39 | if (!sockets.Contains(socket)) 40 | sockets.Add(socket); 41 | } 42 | 43 | public void Remove(WebSocket socket) 44 | { 45 | if (sockets.Contains(socket)) 46 | sockets.Remove(socket); 47 | } 48 | 49 | private void Update() 50 | { 51 | if (sockets.Count <= 0) return; 52 | for (int i = sockets.Count - 1; i >= 0; i--) 53 | { 54 | sockets[i].Update(); 55 | } 56 | } 57 | 58 | private void OnDisable() 59 | { 60 | SocketAbort(); 61 | } 62 | 63 | private void SocketAbort() 64 | { 65 | for (int i = sockets.Count - 1; i >= 0; i--) 66 | { 67 | sockets[i].Abort(); 68 | } 69 | } 70 | } 71 | } 72 | #endif -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/NoWebGL/WebSocketManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99157fb5def394c83a9e5342036c92b0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fb37927ec1ce4def9c5e7cff883f9f5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocket.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_EDITOR && UNITY_WEBGL 2 | using System; 3 | 4 | namespace UnityWebSocket 5 | { 6 | public class WebSocket : IWebSocket 7 | { 8 | public string Address { get; private set; } 9 | public string[] SubProtocols { get; private set; } 10 | public WebSocketState ReadyState { get { return (WebSocketState)WebSocketManager.WebSocketGetState(instanceId); } } 11 | 12 | public event EventHandler OnOpen; 13 | public event EventHandler OnClose; 14 | public event EventHandler OnError; 15 | public event EventHandler OnMessage; 16 | 17 | internal int instanceId = 0; 18 | 19 | public WebSocket(string address) 20 | { 21 | this.Address = address; 22 | AllocateInstance(); 23 | } 24 | 25 | public WebSocket(string address, string subProtocol) 26 | { 27 | this.Address = address; 28 | this.SubProtocols = new string[] { subProtocol }; 29 | AllocateInstance(); 30 | } 31 | 32 | public WebSocket(string address, string[] subProtocols) 33 | { 34 | this.Address = address; 35 | this.SubProtocols = subProtocols; 36 | AllocateInstance(); 37 | } 38 | 39 | internal void AllocateInstance() 40 | { 41 | instanceId = WebSocketManager.AllocateInstance(this.Address); 42 | Log($"Allocate socket with instanceId: {instanceId}"); 43 | if (this.SubProtocols == null) return; 44 | foreach (var protocol in this.SubProtocols) 45 | { 46 | if (string.IsNullOrEmpty(protocol)) continue; 47 | Log($"Add Sub Protocol {protocol}, with instanceId: {instanceId}"); 48 | int code = WebSocketManager.WebSocketAddSubProtocol(instanceId, protocol); 49 | if (code < 0) 50 | { 51 | HandleOnError(GetErrorMessageFromCode(code)); 52 | break; 53 | } 54 | } 55 | } 56 | 57 | ~WebSocket() 58 | { 59 | Log($"Free socket with instanceId: {instanceId}"); 60 | WebSocketManager.WebSocketFree(instanceId); 61 | } 62 | 63 | public void ConnectAsync() 64 | { 65 | Log($"Connect with instanceId: {instanceId}"); 66 | WebSocketManager.Add(this); 67 | int code = WebSocketManager.WebSocketConnect(instanceId); 68 | if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); 69 | } 70 | 71 | public void CloseAsync() 72 | { 73 | Log($"Close with instanceId: {instanceId}"); 74 | int code = WebSocketManager.WebSocketClose(instanceId, (int)CloseStatusCode.Normal, "Normal Closure"); 75 | if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); 76 | } 77 | 78 | public void SendAsync(string text) 79 | { 80 | Log($"Send, type: {Opcode.Text}, size: {text.Length}"); 81 | int code = WebSocketManager.WebSocketSendStr(instanceId, text); 82 | if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); 83 | } 84 | 85 | public void SendAsync(byte[] data) 86 | { 87 | Log($"Send, type: {Opcode.Binary}, size: {data.Length}"); 88 | int code = WebSocketManager.WebSocketSend(instanceId, data, data.Length); 89 | if (code < 0) HandleOnError(GetErrorMessageFromCode(code)); 90 | } 91 | 92 | internal void HandleOnOpen() 93 | { 94 | Log("OnOpen"); 95 | OnOpen?.Invoke(this, new OpenEventArgs()); 96 | } 97 | 98 | internal void HandleOnMessage(byte[] rawData) 99 | { 100 | Log($"OnMessage, type: {Opcode.Binary}, size: {rawData.Length}"); 101 | OnMessage?.Invoke(this, new MessageEventArgs(Opcode.Binary, rawData)); 102 | } 103 | 104 | internal void HandleOnMessageStr(string data) 105 | { 106 | Log($"OnMessage, type: {Opcode.Text}, size: {data.Length}"); 107 | OnMessage?.Invoke(this, new MessageEventArgs(Opcode.Text, data)); 108 | } 109 | 110 | internal void HandleOnClose(ushort code, string reason) 111 | { 112 | Log($"OnClose, code: {code}, reason: {reason}"); 113 | OnClose?.Invoke(this, new CloseEventArgs(code, reason)); 114 | WebSocketManager.Remove(instanceId); 115 | } 116 | 117 | internal void HandleOnError(string msg) 118 | { 119 | Log("OnError, error: " + msg); 120 | OnError?.Invoke(this, new ErrorEventArgs(msg)); 121 | } 122 | 123 | internal static string GetErrorMessageFromCode(int errorCode) 124 | { 125 | switch (errorCode) 126 | { 127 | case -1: return "WebSocket instance not found."; 128 | case -2: return "WebSocket is already connected or in connecting state."; 129 | case -3: return "WebSocket is not connected."; 130 | case -4: return "WebSocket is already closing."; 131 | case -5: return "WebSocket is already closed."; 132 | case -6: return "WebSocket is not in open state."; 133 | case -7: return "Cannot close WebSocket, An invalid code was specified or reason is too long."; 134 | case -8: return "Not support buffer slice. "; 135 | default: return $"Unknown error code {errorCode}."; 136 | } 137 | } 138 | 139 | [System.Diagnostics.Conditional("UNITY_WEB_SOCKET_LOG")] 140 | static void Log(string msg) 141 | { 142 | var time = DateTime.Now.ToString("HH:mm:ss.fff"); 143 | UnityEngine.Debug.Log($"[{time}][UnityWebSocket] {msg}"); 144 | } 145 | } 146 | } 147 | #endif 148 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocket.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74a5b3c22251243d2a2f33e74741559d 3 | timeCreated: 1466578513 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs: -------------------------------------------------------------------------------- 1 | #if !UNITY_EDITOR && UNITY_WEBGL 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | using AOT; 6 | 7 | namespace UnityWebSocket 8 | { 9 | /// 10 | /// Class providing static access methods to work with JSLIB WebSocket 11 | /// 12 | internal static class WebSocketManager 13 | { 14 | /* Map of websocket instances */ 15 | private static Dictionary sockets = new Dictionary(); 16 | 17 | /* Delegates */ 18 | public delegate void OnOpenCallback(int instanceId); 19 | public delegate void OnMessageCallback(int instanceId, IntPtr msgPtr, int msgSize); 20 | public delegate void OnMessageStrCallback(int instanceId, IntPtr msgStrPtr); 21 | public delegate void OnErrorCallback(int instanceId, IntPtr errorPtr); 22 | public delegate void OnCloseCallback(int instanceId, int closeCode, IntPtr reasonPtr); 23 | 24 | /* WebSocket JSLIB functions */ 25 | [DllImport("__Internal")] 26 | public static extern int WebSocketConnect(int instanceId); 27 | 28 | [DllImport("__Internal")] 29 | public static extern int WebSocketClose(int instanceId, int code, string reason); 30 | 31 | [DllImport("__Internal")] 32 | public static extern int WebSocketSend(int instanceId, byte[] dataPtr, int dataLength); 33 | 34 | [DllImport("__Internal")] 35 | public static extern int WebSocketSendStr(int instanceId, string data); 36 | 37 | [DllImport("__Internal")] 38 | public static extern int WebSocketGetState(int instanceId); 39 | 40 | /* WebSocket JSLIB callback setters and other functions */ 41 | [DllImport("__Internal")] 42 | public static extern int WebSocketAllocate(string url); 43 | 44 | [DllImport("__Internal")] 45 | public static extern int WebSocketAddSubProtocol(int instanceId, string protocol); 46 | 47 | [DllImport("__Internal")] 48 | public static extern void WebSocketFree(int instanceId); 49 | 50 | [DllImport("__Internal")] 51 | public static extern void WebSocketSetOnOpen(OnOpenCallback callback); 52 | 53 | [DllImport("__Internal")] 54 | public static extern void WebSocketSetOnMessage(OnMessageCallback callback); 55 | 56 | [DllImport("__Internal")] 57 | public static extern void WebSocketSetOnMessageStr(OnMessageStrCallback callback); 58 | 59 | [DllImport("__Internal")] 60 | public static extern void WebSocketSetOnError(OnErrorCallback callback); 61 | 62 | [DllImport("__Internal")] 63 | public static extern void WebSocketSetOnClose(OnCloseCallback callback); 64 | 65 | [DllImport("__Internal")] 66 | public static extern void WebSocketSetSupport6000(); 67 | 68 | /* If callbacks was initialized and set */ 69 | private static bool isInitialized = false; 70 | 71 | /* Initialize WebSocket callbacks to JSLIB */ 72 | private static void Initialize() 73 | { 74 | WebSocketSetOnOpen(DelegateOnOpenEvent); 75 | WebSocketSetOnMessage(DelegateOnMessageEvent); 76 | WebSocketSetOnMessageStr(DelegateOnMessageStrEvent); 77 | WebSocketSetOnError(DelegateOnErrorEvent); 78 | WebSocketSetOnClose(DelegateOnCloseEvent); 79 | #if UNITY_6000_0_OR_NEWER 80 | WebSocketSetSupport6000(); 81 | #endif 82 | 83 | isInitialized = true; 84 | } 85 | 86 | [MonoPInvokeCallback(typeof(OnOpenCallback))] 87 | public static void DelegateOnOpenEvent(int instanceId) 88 | { 89 | if (sockets.TryGetValue(instanceId, out var socket)) 90 | { 91 | socket.HandleOnOpen(); 92 | } 93 | } 94 | 95 | [MonoPInvokeCallback(typeof(OnMessageCallback))] 96 | public static void DelegateOnMessageEvent(int instanceId, IntPtr msgPtr, int msgSize) 97 | { 98 | if (sockets.TryGetValue(instanceId, out var socket)) 99 | { 100 | var bytes = new byte[msgSize]; 101 | Marshal.Copy(msgPtr, bytes, 0, msgSize); 102 | socket.HandleOnMessage(bytes); 103 | } 104 | } 105 | 106 | [MonoPInvokeCallback(typeof(OnMessageStrCallback))] 107 | public static void DelegateOnMessageStrEvent(int instanceId, IntPtr msgStrPtr) 108 | { 109 | if (sockets.TryGetValue(instanceId, out var socket)) 110 | { 111 | string msgStr = Marshal.PtrToStringAuto(msgStrPtr); 112 | socket.HandleOnMessageStr(msgStr); 113 | } 114 | } 115 | 116 | [MonoPInvokeCallback(typeof(OnErrorCallback))] 117 | public static void DelegateOnErrorEvent(int instanceId, IntPtr errorPtr) 118 | { 119 | if (sockets.TryGetValue(instanceId, out var socket)) 120 | { 121 | string errorMsg = Marshal.PtrToStringAuto(errorPtr); 122 | socket.HandleOnError(errorMsg); 123 | } 124 | } 125 | 126 | [MonoPInvokeCallback(typeof(OnCloseCallback))] 127 | public static void DelegateOnCloseEvent(int instanceId, int closeCode, IntPtr reasonPtr) 128 | { 129 | if (sockets.TryGetValue(instanceId, out var socket)) 130 | { 131 | string reason = Marshal.PtrToStringAuto(reasonPtr); 132 | socket.HandleOnClose((ushort)closeCode, reason); 133 | } 134 | } 135 | 136 | internal static int AllocateInstance(string address) 137 | { 138 | if (!isInitialized) Initialize(); 139 | return WebSocketAllocate(address); 140 | } 141 | 142 | internal static void Add(WebSocket socket) 143 | { 144 | if (!sockets.ContainsKey(socket.instanceId)) 145 | { 146 | sockets.Add(socket.instanceId, socket); 147 | } 148 | } 149 | 150 | internal static void Remove(int instanceId) 151 | { 152 | if (sockets.ContainsKey(instanceId)) 153 | { 154 | sockets.Remove(instanceId); 155 | } 156 | } 157 | } 158 | } 159 | #endif 160 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/Implementation/WebGL/WebSocketManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 246cdc66a1e2047148371a8e56e17d3a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/UnityWebSocket.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "UnityWebSocket.Runtime", 3 | "references": [], 4 | "optionalUnityReferences": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [] 12 | } -------------------------------------------------------------------------------- /Assets/UnityWebSocket/Scripts/Runtime/UnityWebSocket.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b65d8710c3b04373a41cbf6b777ee65 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /CHANGE_LOG.md: -------------------------------------------------------------------------------- 1 | ## 版本记录 2 | 3 | #### v2.2 4 | - 拆分 Git 库,添加对 PackageManager 支持,添加对 OpenUpm 的支持。 5 | 6 | #### v2.1 7 | - 修改WebGL平台Unity - JS通信方式,使用回调方式替换SendMessage方式。 8 | - WebGL平台内存管理,内存优化,主动 malloc 和 free 内存。 9 | - 非WebGL平台内存管理,内存优化,使用对象池方式重复利用对象。 10 | - 添加 辅助工具,包括:Help,About,Check Updates 等。 11 | - 添加 Assembly Define 支持,规范项目依赖,非必要接口使用 internal 关键字不予暴露。 12 | - 目录结构重新整理,使用根路径下唯一UnityWebSocket文件夹作为插件唯一存放位置。 13 | 14 | #### v2.0 15 | - 移除 websocket-sharp 插件,使用 .Net 4.x 内置的 ClientWebSocket 作为非 WebGL 平台下 WebSocket 插件。 16 | - 添加**同步方式**的WebSocket ,使用者不必再考虑**异步回调**中使用 Unity 组件的问题。 17 | 18 | #### v1.3.2 19 | - 修复 非ssl连接,使用sslConfiguration bug。 20 | 21 | #### v1.3.1 22 | - 修复 Tls error,添加默认协议 Tls,Tls11,Tls12。 23 | 24 | #### v1.3 25 | - 移除服务器Demo,改用 [websocket-sharp](http://www.websocket.org/echo.html) 官方提供的测试服务器。 26 | - 添加 PlayerSetting -> Linker Target 属性检测。 27 | 28 | #### v1.2.2 - pre 29 | - support for wss(ssl) 支持SSL协议格式(更新了websocket-sharp源码)。 30 | - 服务器Demo尚未支持 SSL。会在未来版本支持。 31 | 32 | #### v1.2.1 33 | - fix 非WebGL平台打包兼容BUG(屏蔽websocket-jslib部分代码)。 34 | 35 | #### v1.2 36 | - 重构代码,规范代码,模块整理。 37 | - 规范接口,参考websocket-sharp结构,使用EventHandler方式处理事件。 38 | - 添加了字符串数据收发的支持。 39 | - jslib中添加了获取socket.readyState的方法。 40 | - jslib中的SendMessage参数整理。 41 | - fix some Bugs. 42 | 43 | #### v1.1 44 | - 多平台支持,使用websocket-sharp 开源插件。 45 | - 完善项目命名空间,目录结构。 46 | - WebSocket增加异步连接发送方法。(webgl平台下仍调用同步方式) 47 | - 添加开发分支,git管理方式调整。 48 | 49 | #### v1.0 50 | - 支持单客户端同时创建多个不同WebSocket链接。 51 | - 添加OnError错误回调。错误码对应错误原因,参考jslib文件。 52 | - 删除Alert功能(与WebSocket无关,按需求自行添加即可)。 53 | - Close Event Code 作为链接断开错误信息处理。 54 | - jslib 内容完善,增加Map管理websocket实例。 55 | - 修改 State 枚举对应到WebSocket ReadyState。 56 | - 添加 Release Demo Build 文件。 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 psy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.modules.ai": "1.0.0", 4 | "com.unity.modules.androidjni": "1.0.0", 5 | "com.unity.modules.animation": "1.0.0", 6 | "com.unity.modules.assetbundle": "1.0.0", 7 | "com.unity.modules.audio": "1.0.0", 8 | "com.unity.modules.cloth": "1.0.0", 9 | "com.unity.modules.director": "1.0.0", 10 | "com.unity.modules.imageconversion": "1.0.0", 11 | "com.unity.modules.imgui": "1.0.0", 12 | "com.unity.modules.jsonserialize": "1.0.0", 13 | "com.unity.modules.particlesystem": "1.0.0", 14 | "com.unity.modules.physics": "1.0.0", 15 | "com.unity.modules.physics2d": "1.0.0", 16 | "com.unity.modules.screencapture": "1.0.0", 17 | "com.unity.modules.terrain": "1.0.0", 18 | "com.unity.modules.terrainphysics": "1.0.0", 19 | "com.unity.modules.tilemap": "1.0.0", 20 | "com.unity.modules.ui": "1.0.0", 21 | "com.unity.modules.uielements": "1.0.0", 22 | "com.unity.modules.umbra": "1.0.0", 23 | "com.unity.modules.unityanalytics": "1.0.0", 24 | "com.unity.modules.unitywebrequest": "1.0.0", 25 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 26 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 27 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 28 | "com.unity.modules.unitywebrequestwww": "1.0.0", 29 | "com.unity.modules.vehicles": "1.0.0", 30 | "com.unity.modules.video": "1.0.0", 31 | "com.unity.modules.vr": "1.0.0", 32 | "com.unity.modules.wind": "1.0.0", 33 | "com.unity.modules.xr": "1.0.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.modules.ai": { 4 | "version": "1.0.0", 5 | "depth": 0, 6 | "source": "builtin", 7 | "dependencies": {} 8 | }, 9 | "com.unity.modules.androidjni": { 10 | "version": "1.0.0", 11 | "depth": 0, 12 | "source": "builtin", 13 | "dependencies": {} 14 | }, 15 | "com.unity.modules.animation": { 16 | "version": "1.0.0", 17 | "depth": 0, 18 | "source": "builtin", 19 | "dependencies": {} 20 | }, 21 | "com.unity.modules.assetbundle": { 22 | "version": "1.0.0", 23 | "depth": 0, 24 | "source": "builtin", 25 | "dependencies": {} 26 | }, 27 | "com.unity.modules.audio": { 28 | "version": "1.0.0", 29 | "depth": 0, 30 | "source": "builtin", 31 | "dependencies": {} 32 | }, 33 | "com.unity.modules.cloth": { 34 | "version": "1.0.0", 35 | "depth": 0, 36 | "source": "builtin", 37 | "dependencies": { 38 | "com.unity.modules.physics": "1.0.0" 39 | } 40 | }, 41 | "com.unity.modules.director": { 42 | "version": "1.0.0", 43 | "depth": 0, 44 | "source": "builtin", 45 | "dependencies": { 46 | "com.unity.modules.audio": "1.0.0", 47 | "com.unity.modules.animation": "1.0.0" 48 | } 49 | }, 50 | "com.unity.modules.imageconversion": { 51 | "version": "1.0.0", 52 | "depth": 0, 53 | "source": "builtin", 54 | "dependencies": {} 55 | }, 56 | "com.unity.modules.imgui": { 57 | "version": "1.0.0", 58 | "depth": 0, 59 | "source": "builtin", 60 | "dependencies": {} 61 | }, 62 | "com.unity.modules.jsonserialize": { 63 | "version": "1.0.0", 64 | "depth": 0, 65 | "source": "builtin", 66 | "dependencies": {} 67 | }, 68 | "com.unity.modules.particlesystem": { 69 | "version": "1.0.0", 70 | "depth": 0, 71 | "source": "builtin", 72 | "dependencies": {} 73 | }, 74 | "com.unity.modules.physics": { 75 | "version": "1.0.0", 76 | "depth": 0, 77 | "source": "builtin", 78 | "dependencies": {} 79 | }, 80 | "com.unity.modules.physics2d": { 81 | "version": "1.0.0", 82 | "depth": 0, 83 | "source": "builtin", 84 | "dependencies": {} 85 | }, 86 | "com.unity.modules.screencapture": { 87 | "version": "1.0.0", 88 | "depth": 0, 89 | "source": "builtin", 90 | "dependencies": { 91 | "com.unity.modules.imageconversion": "1.0.0" 92 | } 93 | }, 94 | "com.unity.modules.subsystems": { 95 | "version": "1.0.0", 96 | "depth": 1, 97 | "source": "builtin", 98 | "dependencies": { 99 | "com.unity.modules.jsonserialize": "1.0.0" 100 | } 101 | }, 102 | "com.unity.modules.terrain": { 103 | "version": "1.0.0", 104 | "depth": 0, 105 | "source": "builtin", 106 | "dependencies": {} 107 | }, 108 | "com.unity.modules.terrainphysics": { 109 | "version": "1.0.0", 110 | "depth": 0, 111 | "source": "builtin", 112 | "dependencies": { 113 | "com.unity.modules.physics": "1.0.0", 114 | "com.unity.modules.terrain": "1.0.0" 115 | } 116 | }, 117 | "com.unity.modules.tilemap": { 118 | "version": "1.0.0", 119 | "depth": 0, 120 | "source": "builtin", 121 | "dependencies": { 122 | "com.unity.modules.physics2d": "1.0.0" 123 | } 124 | }, 125 | "com.unity.modules.ui": { 126 | "version": "1.0.0", 127 | "depth": 0, 128 | "source": "builtin", 129 | "dependencies": {} 130 | }, 131 | "com.unity.modules.uielements": { 132 | "version": "1.0.0", 133 | "depth": 0, 134 | "source": "builtin", 135 | "dependencies": { 136 | "com.unity.modules.imgui": "1.0.0", 137 | "com.unity.modules.jsonserialize": "1.0.0" 138 | } 139 | }, 140 | "com.unity.modules.umbra": { 141 | "version": "1.0.0", 142 | "depth": 0, 143 | "source": "builtin", 144 | "dependencies": {} 145 | }, 146 | "com.unity.modules.unityanalytics": { 147 | "version": "1.0.0", 148 | "depth": 0, 149 | "source": "builtin", 150 | "dependencies": { 151 | "com.unity.modules.unitywebrequest": "1.0.0", 152 | "com.unity.modules.jsonserialize": "1.0.0" 153 | } 154 | }, 155 | "com.unity.modules.unitywebrequest": { 156 | "version": "1.0.0", 157 | "depth": 0, 158 | "source": "builtin", 159 | "dependencies": {} 160 | }, 161 | "com.unity.modules.unitywebrequestassetbundle": { 162 | "version": "1.0.0", 163 | "depth": 0, 164 | "source": "builtin", 165 | "dependencies": { 166 | "com.unity.modules.assetbundle": "1.0.0", 167 | "com.unity.modules.unitywebrequest": "1.0.0" 168 | } 169 | }, 170 | "com.unity.modules.unitywebrequestaudio": { 171 | "version": "1.0.0", 172 | "depth": 0, 173 | "source": "builtin", 174 | "dependencies": { 175 | "com.unity.modules.unitywebrequest": "1.0.0", 176 | "com.unity.modules.audio": "1.0.0" 177 | } 178 | }, 179 | "com.unity.modules.unitywebrequesttexture": { 180 | "version": "1.0.0", 181 | "depth": 0, 182 | "source": "builtin", 183 | "dependencies": { 184 | "com.unity.modules.unitywebrequest": "1.0.0", 185 | "com.unity.modules.imageconversion": "1.0.0" 186 | } 187 | }, 188 | "com.unity.modules.unitywebrequestwww": { 189 | "version": "1.0.0", 190 | "depth": 0, 191 | "source": "builtin", 192 | "dependencies": { 193 | "com.unity.modules.unitywebrequest": "1.0.0", 194 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 195 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 196 | "com.unity.modules.audio": "1.0.0", 197 | "com.unity.modules.assetbundle": "1.0.0", 198 | "com.unity.modules.imageconversion": "1.0.0" 199 | } 200 | }, 201 | "com.unity.modules.vehicles": { 202 | "version": "1.0.0", 203 | "depth": 0, 204 | "source": "builtin", 205 | "dependencies": { 206 | "com.unity.modules.physics": "1.0.0" 207 | } 208 | }, 209 | "com.unity.modules.video": { 210 | "version": "1.0.0", 211 | "depth": 0, 212 | "source": "builtin", 213 | "dependencies": { 214 | "com.unity.modules.audio": "1.0.0", 215 | "com.unity.modules.ui": "1.0.0", 216 | "com.unity.modules.unitywebrequest": "1.0.0" 217 | } 218 | }, 219 | "com.unity.modules.vr": { 220 | "version": "1.0.0", 221 | "depth": 0, 222 | "source": "builtin", 223 | "dependencies": { 224 | "com.unity.modules.jsonserialize": "1.0.0", 225 | "com.unity.modules.physics": "1.0.0", 226 | "com.unity.modules.xr": "1.0.0" 227 | } 228 | }, 229 | "com.unity.modules.wind": { 230 | "version": "1.0.0", 231 | "depth": 0, 232 | "source": "builtin", 233 | "dependencies": {} 234 | }, 235 | "com.unity.modules.xr": { 236 | "version": "1.0.0", 237 | "depth": 0, 238 | "source": "builtin", 239 | "dependencies": { 240 | "com.unity.modules.physics": "1.0.0", 241 | "com.unity.modules.jsonserialize": "1.0.0", 242 | "com.unity.modules.subsystems": "1.0.0" 243 | } 244 | } 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 1 23 | m_ClothInterCollisionSettingsToggle: 0 24 | m_ContactPairsMode: 0 25 | m_BroadphaseType: 0 26 | m_WorldBounds: 27 | m_Center: {x: 0, y: 0, z: 0} 28 | m_Extent: {x: 250, y: 250, z: 250} 29 | m_WorldSubdivisions: 8 30 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/UnityWebSocket/Demo/DemoScene.unity 10 | guid: 65671216fb4e42d4f89ed6eeca36060d 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Hidden Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 1 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} 40 | m_PreloadedShaders: [] 41 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 42 | type: 0} 43 | m_CustomRenderPipeline: {fileID: 0} 44 | m_TransparencySortMode: 0 45 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 46 | m_DefaultRenderingPath: 1 47 | m_DefaultMobileRenderingPath: 1 48 | m_TierSettings: [] 49 | m_LightmapStripping: 0 50 | m_FogStripping: 0 51 | m_InstancingStripping: 0 52 | m_LightmapKeepPlain: 1 53 | m_LightmapKeepDirCombined: 1 54 | m_LightmapKeepDynamicPlain: 1 55 | m_LightmapKeepDynamicDirCombined: 1 56 | m_LightmapKeepShadowMask: 1 57 | m_LightmapKeepSubtractive: 1 58 | m_FogKeepLinear: 1 59 | m_FogKeepExp: 1 60 | m_FogKeepExp2: 1 61 | m_AlbedoSwatchInfos: [] 62 | m_LightsUseLinearIntensity: 0 63 | m_LightsUseColorTemperature: 0 64 | m_LogWhenShaderIsCompiled: 0 65 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_AutoSyncTransforms: 1 28 | m_AlwaysShowColliders: 0 29 | m_ShowColliderSleep: 1 30 | m_ShowColliderContacts: 0 31 | m_ShowColliderAABB: 0 32 | m_ContactArrowScale: 0.2 33 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 34 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 35 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 36 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 37 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 38 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 18 7 | productGUID: 5293469bee108a549bc87040c1aa74f5 8 | AndroidProfiler: 0 9 | AndroidFilterTouchesWhenObscured: 0 10 | AndroidEnableSustainedPerformanceMode: 0 11 | defaultScreenOrientation: 4 12 | targetDevice: 2 13 | useOnDemandResources: 0 14 | accelerometerFrequency: 60 15 | companyName: com.psygame 16 | productName: UnityWebsocket 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} 20 | m_ShowUnitySplashScreen: 1 21 | m_ShowUnitySplashLogo: 1 22 | m_SplashScreenOverlayOpacity: 1 23 | m_SplashScreenAnimation: 1 24 | m_SplashScreenLogoStyle: 1 25 | m_SplashScreenDrawMode: 0 26 | m_SplashScreenBackgroundAnimationZoom: 1 27 | m_SplashScreenLogoAnimationZoom: 1 28 | m_SplashScreenBackgroundLandscapeAspect: 1 29 | m_SplashScreenBackgroundPortraitAspect: 1 30 | m_SplashScreenBackgroundLandscapeUvs: 31 | serializedVersion: 2 32 | x: 0 33 | y: 0 34 | width: 1 35 | height: 1 36 | m_SplashScreenBackgroundPortraitUvs: 37 | serializedVersion: 2 38 | x: 0 39 | y: 0 40 | width: 1 41 | height: 1 42 | m_SplashScreenLogos: [] 43 | m_VirtualRealitySplashScreen: {fileID: 0} 44 | m_ShowUnitySplashAds: 0 45 | m_AdsAndroidGameId: 46 | m_AdsIosGameId: 47 | m_ShowSplashAdsSlogan: 0 48 | m_SloganImage: {fileID: 0} 49 | m_SloganHeight: 150 50 | m_HolographicTrackingLossScreen: {fileID: 0} 51 | defaultScreenWidth: 1024 52 | defaultScreenHeight: 768 53 | defaultScreenWidthWeb: 960 54 | defaultScreenHeightWeb: 600 55 | m_StereoRenderingPath: 0 56 | m_ActiveColorSpace: 0 57 | m_MTRendering: 1 58 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000 59 | iosShowActivityIndicatorOnLoading: -1 60 | androidShowActivityIndicatorOnLoading: -1 61 | displayResolutionDialog: 1 62 | iosUseCustomAppBackgroundBehavior: 0 63 | iosAllowHTTPDownload: 1 64 | allowedAutorotateToPortrait: 1 65 | allowedAutorotateToPortraitUpsideDown: 1 66 | allowedAutorotateToLandscapeRight: 1 67 | allowedAutorotateToLandscapeLeft: 1 68 | useOSAutorotation: 1 69 | use32BitDisplayBuffer: 1 70 | preserveFramebufferAlpha: 0 71 | disableDepthAndStencilBuffers: 0 72 | androidStartInFullscreen: 1 73 | androidRenderOutsideSafeArea: 0 74 | androidBlitType: 0 75 | defaultIsNativeResolution: 1 76 | macRetinaSupport: 1 77 | runInBackground: 1 78 | captureSingleScreen: 0 79 | muteOtherAudioSources: 0 80 | Prepare IOS For Recording: 0 81 | Force IOS Speakers When Recording: 0 82 | deferSystemGesturesMode: 0 83 | hideHomeButton: 0 84 | submitAnalytics: 1 85 | usePlayerLog: 1 86 | bakeCollisionMeshes: 0 87 | forceSingleInstance: 0 88 | resizableWindow: 0 89 | useMacAppStoreValidation: 0 90 | macAppStoreCategory: public.app-category.games 91 | gpuSkinning: 0 92 | graphicsJobs: 0 93 | xboxPIXTextureCapture: 0 94 | xboxEnableAvatar: 0 95 | xboxEnableKinect: 0 96 | xboxEnableKinectAutoTracking: 0 97 | xboxEnableFitness: 0 98 | visibleInBackground: 1 99 | allowFullscreenSwitch: 1 100 | graphicsJobMode: 0 101 | fullscreenMode: 1 102 | xboxSpeechDB: 0 103 | xboxEnableHeadOrientation: 0 104 | xboxEnableGuest: 0 105 | xboxEnablePIXSampling: 0 106 | metalFramebufferOnly: 0 107 | xboxOneResolution: 0 108 | xboxOneSResolution: 0 109 | xboxOneXResolution: 3 110 | xboxOneMonoLoggingLevel: 0 111 | xboxOneLoggingLevel: 1 112 | xboxOneDisableEsram: 0 113 | xboxOneEnableTypeOptimization: 0 114 | xboxOnePresentImmediateThreshold: 0 115 | switchQueueCommandMemory: 0 116 | switchQueueControlMemory: 16384 117 | switchQueueComputeMemory: 262144 118 | switchNVNShaderPoolsGranularity: 33554432 119 | switchNVNDefaultPoolsGranularity: 16777216 120 | switchNVNOtherPoolsGranularity: 16777216 121 | switchNVNMaxPublicTextureIDCount: 0 122 | switchNVNMaxPublicSamplerIDCount: 0 123 | vulkanEnableSetSRGBWrite: 0 124 | useSecurityBuild: 0 125 | m_SupportedAspectRatios: 126 | 4:3: 1 127 | 5:4: 1 128 | 16:10: 1 129 | 16:9: 1 130 | Others: 1 131 | bundleVersion: 2.8.1 132 | preloadedAssets: [] 133 | metroInputSource: 0 134 | wsaTransparentSwapchain: 0 135 | m_HolographicPauseOnTrackingLoss: 1 136 | xboxOneDisableKinectGpuReservation: 0 137 | xboxOneEnable7thCore: 0 138 | isWsaHolographicRemotingEnabled: 0 139 | vrSettings: 140 | cardboard: 141 | depthFormat: 0 142 | enableTransitionView: 0 143 | daydream: 144 | depthFormat: 0 145 | useSustainedPerformanceMode: 0 146 | enableVideoLayer: 0 147 | useProtectedVideoMemory: 0 148 | minimumSupportedHeadTracking: 0 149 | maximumSupportedHeadTracking: 1 150 | hololens: 151 | depthFormat: 1 152 | depthBufferSharingEnabled: 0 153 | oculus: 154 | sharedDepthBuffer: 0 155 | dashSupport: 0 156 | lowOverheadMode: 0 157 | protectedContext: 0 158 | v2Signing: 0 159 | enable360StereoCapture: 0 160 | protectGraphicsMemory: 0 161 | enableFrameTimingStats: 0 162 | useHDRDisplay: 0 163 | m_ColorGamuts: 00000000 164 | targetPixelDensity: 30 165 | resolutionScalingMode: 0 166 | androidSupportedAspectRatio: 1 167 | androidMaxAspectRatio: 2.1 168 | applicationIdentifier: 169 | Android: com.redstone.UnityWebsocket 170 | buildNumber: {} 171 | AndroidBundleVersionCode: 1 172 | AndroidMinSdkVersion: 16 173 | AndroidTargetSdkVersion: 0 174 | AndroidPreferredInstallLocation: 1 175 | aotOptions: 176 | stripEngineCode: 1 177 | iPhoneStrippingLevel: 0 178 | iPhoneScriptCallOptimization: 0 179 | ForceInternetPermission: 0 180 | ForceSDCardPermission: 0 181 | CreateWallpaper: 0 182 | APKExpansionFiles: 0 183 | keepLoadedShadersAlive: 0 184 | StripUnusedMeshComponents: 0 185 | VertexChannelCompressionMask: 214 186 | iPhoneSdkVersion: 988 187 | iOSTargetOSVersionString: 9.0 188 | tvOSSdkVersion: 0 189 | tvOSRequireExtendedGameController: 0 190 | tvOSTargetOSVersionString: 9.0 191 | uIPrerenderedIcon: 0 192 | uIRequiresPersistentWiFi: 0 193 | uIRequiresFullScreen: 1 194 | uIStatusBarHidden: 1 195 | uIExitOnSuspend: 0 196 | uIStatusBarStyle: 0 197 | iPhoneSplashScreen: {fileID: 0} 198 | iPhoneHighResSplashScreen: {fileID: 0} 199 | iPhoneTallHighResSplashScreen: {fileID: 0} 200 | iPhone47inSplashScreen: {fileID: 0} 201 | iPhone55inPortraitSplashScreen: {fileID: 0} 202 | iPhone55inLandscapeSplashScreen: {fileID: 0} 203 | iPhone58inPortraitSplashScreen: {fileID: 0} 204 | iPhone58inLandscapeSplashScreen: {fileID: 0} 205 | iPadPortraitSplashScreen: {fileID: 0} 206 | iPadHighResPortraitSplashScreen: {fileID: 0} 207 | iPadLandscapeSplashScreen: {fileID: 0} 208 | iPadHighResLandscapeSplashScreen: {fileID: 0} 209 | appleTVSplashScreen: {fileID: 0} 210 | appleTVSplashScreen2x: {fileID: 0} 211 | tvOSSmallIconLayers: [] 212 | tvOSSmallIconLayers2x: [] 213 | tvOSLargeIconLayers: [] 214 | tvOSLargeIconLayers2x: [] 215 | tvOSTopShelfImageLayers: [] 216 | tvOSTopShelfImageLayers2x: [] 217 | tvOSTopShelfImageWideLayers: [] 218 | tvOSTopShelfImageWideLayers2x: [] 219 | iOSLaunchScreenType: 0 220 | iOSLaunchScreenPortrait: {fileID: 0} 221 | iOSLaunchScreenLandscape: {fileID: 0} 222 | iOSLaunchScreenBackgroundColor: 223 | serializedVersion: 2 224 | rgba: 0 225 | iOSLaunchScreenFillPct: 100 226 | iOSLaunchScreenSize: 100 227 | iOSLaunchScreenCustomXibPath: 228 | iOSLaunchScreeniPadType: 0 229 | iOSLaunchScreeniPadImage: {fileID: 0} 230 | iOSLaunchScreeniPadBackgroundColor: 231 | serializedVersion: 2 232 | rgba: 0 233 | iOSLaunchScreeniPadFillPct: 100 234 | iOSLaunchScreeniPadSize: 100 235 | iOSLaunchScreeniPadCustomXibPath: 236 | iOSUseLaunchScreenStoryboard: 0 237 | iOSLaunchScreenCustomStoryboardPath: 238 | iOSDeviceRequirements: [] 239 | iOSURLSchemes: [] 240 | iOSBackgroundModes: 0 241 | iOSMetalForceHardShadows: 0 242 | metalEditorSupport: 1 243 | metalAPIValidation: 1 244 | iOSRenderExtraFrameOnPause: 0 245 | appleDeveloperTeamID: 246 | iOSManualSigningProvisioningProfileID: 247 | tvOSManualSigningProvisioningProfileID: 248 | iOSManualSigningProvisioningProfileType: 0 249 | tvOSManualSigningProvisioningProfileType: 0 250 | appleEnableAutomaticSigning: 0 251 | iOSRequireARKit: 0 252 | iOSAutomaticallyDetectAndAddCapabilities: 1 253 | appleEnableProMotion: 0 254 | clonedFromGUID: 00000000000000000000000000000000 255 | templatePackageId: 256 | templateDefaultScene: 257 | AndroidTargetArchitectures: 5 258 | AndroidSplashScreenScale: 0 259 | androidSplashScreen: {fileID: 0} 260 | AndroidKeystoreName: 261 | AndroidKeyaliasName: 262 | AndroidBuildApkPerCpuArchitecture: 0 263 | AndroidTVCompatibility: 1 264 | AndroidIsGame: 1 265 | AndroidEnableTango: 0 266 | androidEnableBanner: 1 267 | androidUseLowAccuracyLocation: 0 268 | m_AndroidBanners: 269 | - width: 320 270 | height: 180 271 | banner: {fileID: 0} 272 | androidGamepadSupportLevel: 0 273 | resolutionDialogBanner: {fileID: 0} 274 | m_BuildTargetIcons: [] 275 | m_BuildTargetPlatformIcons: [] 276 | m_BuildTargetBatching: [] 277 | m_BuildTargetEncrypting: [] 278 | m_BuildTargetGraphicsAPIs: [] 279 | m_BuildTargetVRSettings: [] 280 | m_BuildTargetEnableVuforiaSettings: [] 281 | openGLRequireES31: 0 282 | openGLRequireES31AEP: 0 283 | m_TemplateCustomTags: {} 284 | mobileMTRendering: 285 | Android: 1 286 | iPhone: 1 287 | tvOS: 1 288 | m_BuildTargetGroupLightmapEncodingQuality: [] 289 | m_BuildTargetGroupLightmapSettings: [] 290 | playModeTestRunnerEnabled: 0 291 | runPlayModeTestAsEditModeTest: 0 292 | actionOnDotNetUnhandledException: 1 293 | enableInternalProfiler: 0 294 | logObjCUncaughtExceptions: 1 295 | enableCrashReportAPI: 0 296 | cameraUsageDescription: 297 | locationUsageDescription: 298 | microphoneUsageDescription: 299 | switchNetLibKey: 300 | switchSocketMemoryPoolSize: 6144 301 | switchSocketAllocatorPoolSize: 128 302 | switchSocketConcurrencyLimit: 14 303 | switchScreenResolutionBehavior: 2 304 | switchUseCPUProfiler: 0 305 | switchApplicationID: 0x01004b9000490000 306 | switchNSODependencies: 307 | switchTitleNames_0: 308 | switchTitleNames_1: 309 | switchTitleNames_2: 310 | switchTitleNames_3: 311 | switchTitleNames_4: 312 | switchTitleNames_5: 313 | switchTitleNames_6: 314 | switchTitleNames_7: 315 | switchTitleNames_8: 316 | switchTitleNames_9: 317 | switchTitleNames_10: 318 | switchTitleNames_11: 319 | switchTitleNames_12: 320 | switchTitleNames_13: 321 | switchTitleNames_14: 322 | switchPublisherNames_0: 323 | switchPublisherNames_1: 324 | switchPublisherNames_2: 325 | switchPublisherNames_3: 326 | switchPublisherNames_4: 327 | switchPublisherNames_5: 328 | switchPublisherNames_6: 329 | switchPublisherNames_7: 330 | switchPublisherNames_8: 331 | switchPublisherNames_9: 332 | switchPublisherNames_10: 333 | switchPublisherNames_11: 334 | switchPublisherNames_12: 335 | switchPublisherNames_13: 336 | switchPublisherNames_14: 337 | switchIcons_0: {fileID: 0} 338 | switchIcons_1: {fileID: 0} 339 | switchIcons_2: {fileID: 0} 340 | switchIcons_3: {fileID: 0} 341 | switchIcons_4: {fileID: 0} 342 | switchIcons_5: {fileID: 0} 343 | switchIcons_6: {fileID: 0} 344 | switchIcons_7: {fileID: 0} 345 | switchIcons_8: {fileID: 0} 346 | switchIcons_9: {fileID: 0} 347 | switchIcons_10: {fileID: 0} 348 | switchIcons_11: {fileID: 0} 349 | switchIcons_12: {fileID: 0} 350 | switchIcons_13: {fileID: 0} 351 | switchIcons_14: {fileID: 0} 352 | switchSmallIcons_0: {fileID: 0} 353 | switchSmallIcons_1: {fileID: 0} 354 | switchSmallIcons_2: {fileID: 0} 355 | switchSmallIcons_3: {fileID: 0} 356 | switchSmallIcons_4: {fileID: 0} 357 | switchSmallIcons_5: {fileID: 0} 358 | switchSmallIcons_6: {fileID: 0} 359 | switchSmallIcons_7: {fileID: 0} 360 | switchSmallIcons_8: {fileID: 0} 361 | switchSmallIcons_9: {fileID: 0} 362 | switchSmallIcons_10: {fileID: 0} 363 | switchSmallIcons_11: {fileID: 0} 364 | switchSmallIcons_12: {fileID: 0} 365 | switchSmallIcons_13: {fileID: 0} 366 | switchSmallIcons_14: {fileID: 0} 367 | switchManualHTML: 368 | switchAccessibleURLs: 369 | switchLegalInformation: 370 | switchMainThreadStackSize: 1048576 371 | switchPresenceGroupId: 372 | switchLogoHandling: 0 373 | switchReleaseVersion: 0 374 | switchDisplayVersion: 1.0.0 375 | switchStartupUserAccount: 0 376 | switchTouchScreenUsage: 0 377 | switchSupportedLanguagesMask: 0 378 | switchLogoType: 0 379 | switchApplicationErrorCodeCategory: 380 | switchUserAccountSaveDataSize: 0 381 | switchUserAccountSaveDataJournalSize: 0 382 | switchApplicationAttribute: 0 383 | switchCardSpecSize: -1 384 | switchCardSpecClock: -1 385 | switchRatingsMask: 0 386 | switchRatingsInt_0: 0 387 | switchRatingsInt_1: 0 388 | switchRatingsInt_2: 0 389 | switchRatingsInt_3: 0 390 | switchRatingsInt_4: 0 391 | switchRatingsInt_5: 0 392 | switchRatingsInt_6: 0 393 | switchRatingsInt_7: 0 394 | switchRatingsInt_8: 0 395 | switchRatingsInt_9: 0 396 | switchRatingsInt_10: 0 397 | switchRatingsInt_11: 0 398 | switchRatingsInt_12: 0 399 | switchLocalCommunicationIds_0: 400 | switchLocalCommunicationIds_1: 401 | switchLocalCommunicationIds_2: 402 | switchLocalCommunicationIds_3: 403 | switchLocalCommunicationIds_4: 404 | switchLocalCommunicationIds_5: 405 | switchLocalCommunicationIds_6: 406 | switchLocalCommunicationIds_7: 407 | switchParentalControl: 0 408 | switchAllowsScreenshot: 1 409 | switchAllowsVideoCapturing: 1 410 | switchAllowsRuntimeAddOnContentInstall: 0 411 | switchDataLossConfirmation: 0 412 | switchUserAccountLockEnabled: 0 413 | switchSystemResourceMemory: 16777216 414 | switchSupportedNpadStyles: 3 415 | switchNativeFsCacheSize: 32 416 | switchIsHoldTypeHorizontal: 0 417 | switchSupportedNpadCount: 8 418 | switchSocketConfigEnabled: 0 419 | switchTcpInitialSendBufferSize: 32 420 | switchTcpInitialReceiveBufferSize: 64 421 | switchTcpAutoSendBufferSizeMax: 256 422 | switchTcpAutoReceiveBufferSizeMax: 256 423 | switchUdpSendBufferSize: 9 424 | switchUdpReceiveBufferSize: 42 425 | switchSocketBufferEfficiency: 4 426 | switchSocketInitializeEnabled: 1 427 | switchNetworkInterfaceManagerInitializeEnabled: 1 428 | switchPlayerConnectionEnabled: 1 429 | ps4NPAgeRating: 12 430 | ps4NPTitleSecret: 431 | ps4NPTrophyPackPath: 432 | ps4ParentalLevel: 11 433 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 434 | ps4Category: 0 435 | ps4MasterVersion: 01.00 436 | ps4AppVersion: 01.00 437 | ps4AppType: 0 438 | ps4ParamSfxPath: 439 | ps4VideoOutPixelFormat: 0 440 | ps4VideoOutInitialWidth: 1920 441 | ps4VideoOutBaseModeInitialWidth: 1920 442 | ps4VideoOutReprojectionRate: 60 443 | ps4PronunciationXMLPath: 444 | ps4PronunciationSIGPath: 445 | ps4BackgroundImagePath: 446 | ps4StartupImagePath: 447 | ps4StartupImagesFolder: 448 | ps4IconImagesFolder: 449 | ps4SaveDataImagePath: 450 | ps4SdkOverride: 451 | ps4BGMPath: 452 | ps4ShareFilePath: 453 | ps4ShareOverlayImagePath: 454 | ps4PrivacyGuardImagePath: 455 | ps4ExtraSceSysFile: 456 | ps4NPtitleDatPath: 457 | ps4RemotePlayKeyAssignment: -1 458 | ps4RemotePlayKeyMappingDir: 459 | ps4PlayTogetherPlayerCount: 0 460 | ps4EnterButtonAssignment: 1 461 | ps4ApplicationParam1: 0 462 | ps4ApplicationParam2: 0 463 | ps4ApplicationParam3: 0 464 | ps4ApplicationParam4: 0 465 | ps4DownloadDataSize: 0 466 | ps4GarlicHeapSize: 2048 467 | ps4ProGarlicHeapSize: 2560 468 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 469 | ps4pnSessions: 1 470 | ps4pnPresence: 1 471 | ps4pnFriends: 1 472 | ps4pnGameCustomData: 1 473 | playerPrefsSupport: 0 474 | enableApplicationExit: 0 475 | resetTempFolder: 1 476 | restrictedAudioUsageRights: 0 477 | ps4UseResolutionFallback: 0 478 | ps4ReprojectionSupport: 0 479 | ps4UseAudio3dBackend: 0 480 | ps4SocialScreenEnabled: 0 481 | ps4ScriptOptimizationLevel: 0 482 | ps4Audio3dVirtualSpeakerCount: 14 483 | ps4attribCpuUsage: 0 484 | ps4PatchPkgPath: 485 | ps4PatchLatestPkgPath: 486 | ps4PatchChangeinfoPath: 487 | ps4PatchDayOne: 0 488 | ps4attribUserManagement: 0 489 | ps4attribMoveSupport: 0 490 | ps4attrib3DSupport: 0 491 | ps4attribShareSupport: 0 492 | ps4attribExclusiveVR: 0 493 | ps4disableAutoHideSplash: 0 494 | ps4videoRecordingFeaturesUsed: 0 495 | ps4contentSearchFeaturesUsed: 0 496 | ps4CompatibilityPS5: 0 497 | ps4GPU800MHz: 1 498 | ps4attribEyeToEyeDistanceSettingVR: 0 499 | ps4IncludedModules: [] 500 | monoEnv: 501 | splashScreenBackgroundSourceLandscape: {fileID: 0} 502 | splashScreenBackgroundSourcePortrait: {fileID: 0} 503 | spritePackerPolicy: 504 | webGLMemorySize: 256 505 | webGLExceptionSupport: 1 506 | webGLNameFilesAsHashes: 0 507 | webGLDataCaching: 0 508 | webGLDebugSymbols: 0 509 | webGLEmscriptenArgs: 510 | webGLModulesDirectory: 511 | webGLTemplate: APPLICATION:Default 512 | webGLAnalyzeBuildSize: 0 513 | webGLUseEmbeddedResources: 0 514 | webGLCompressionFormat: 1 515 | webGLLinkerTarget: 1 516 | webGLThreadsSupport: 0 517 | scriptingDefineSymbols: 518 | 1: 519 | platformArchitecture: {} 520 | scriptingBackend: 521 | Standalone: 0 522 | il2cppCompilerConfiguration: {} 523 | managedStrippingLevel: {} 524 | incrementalIl2cppBuild: {} 525 | allowUnsafeCode: 0 526 | additionalIl2CppArgs: 527 | scriptingRuntimeVersion: 1 528 | apiCompatibilityLevelPerPlatform: {} 529 | m_RenderingPath: 1 530 | m_MobileRenderingPath: 1 531 | metroPackageName: UnityWebsocket 532 | metroPackageVersion: 533 | metroCertificatePath: 534 | metroCertificatePassword: 535 | metroCertificateSubject: 536 | metroCertificateIssuer: 537 | metroCertificateNotAfter: 0000000000000000 538 | metroApplicationDescription: UnityWebsocket 539 | wsaImages: {} 540 | metroTileShortName: 541 | metroTileShowName: 0 542 | metroMediumTileShowName: 0 543 | metroLargeTileShowName: 0 544 | metroWideTileShowName: 0 545 | metroSupportStreamingInstall: 0 546 | metroLastRequiredScene: 0 547 | metroDefaultTileSize: 1 548 | metroTileForegroundText: 2 549 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 550 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 551 | a: 1} 552 | metroSplashScreenUseBackgroundColor: 0 553 | platformCapabilities: {} 554 | metroTargetDeviceFamilies: {} 555 | metroFTAName: 556 | metroFTAFileTypes: [] 557 | metroProtocolName: 558 | metroCompilationOverrides: 1 559 | XboxOneProductId: 560 | XboxOneUpdateKey: 561 | XboxOneSandboxId: 562 | XboxOneContentId: 563 | XboxOneTitleId: 564 | XboxOneSCId: 565 | XboxOneGameOsOverridePath: 566 | XboxOnePackagingOverridePath: 567 | XboxOneAppManifestOverridePath: 568 | XboxOneVersion: 1.0.0.0 569 | XboxOnePackageEncryption: 0 570 | XboxOnePackageUpdateGranularity: 2 571 | XboxOneDescription: 572 | XboxOneLanguage: 573 | - enus 574 | XboxOneCapability: [] 575 | XboxOneGameRating: {} 576 | XboxOneIsContentPackage: 0 577 | XboxOneEnableGPUVariability: 0 578 | XboxOneSockets: {} 579 | XboxOneSplashScreen: {fileID: 0} 580 | XboxOneAllowedProductIds: [] 581 | XboxOnePersistentLocalStorageSize: 0 582 | XboxOneXTitleMemory: 8 583 | xboxOneScriptCompiler: 0 584 | XboxOneOverrideIdentityName: 585 | vrEditorSettings: 586 | daydream: 587 | daydreamIconForeground: {fileID: 0} 588 | daydreamIconBackground: {fileID: 0} 589 | cloudServicesEnabled: {} 590 | luminIcon: 591 | m_Name: 592 | m_ModelFolderPath: 593 | m_PortalFolderPath: 594 | luminCert: 595 | m_CertPath: 596 | m_PrivateKeyPath: 597 | luminIsChannelApp: 0 598 | luminVersion: 599 | m_VersionCode: 1 600 | m_VersionName: 601 | facebookSdkVersion: 7.9.4 602 | facebookAppId: 603 | facebookCookies: 1 604 | facebookLogging: 1 605 | facebookStatus: 1 606 | facebookXfbml: 0 607 | facebookFrictionlessRequests: 1 608 | apiCompatibilityLevel: 6 609 | cloudProjectId: 610 | framebufferDepthMemorylessMode: 0 611 | projectName: 612 | organizationId: 613 | cloudEnabled: 0 614 | enableNativePlatformBackendsForNewInputSystem: 0 615 | disableOldInputManagerSupport: 0 616 | legacyClampBlendShapeWeights: 1 617 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.4.27f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 4 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 4 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 1 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 1 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 4 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 2 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 1 108 | antiAliasing: 0 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 1 112 | billboardsFaceCameraPosition: 1 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 4 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 2 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 70 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 2 136 | antiAliasing: 2 137 | softParticles: 1 138 | softVegetation: 1 139 | realtimeReflectionProbes: 1 140 | billboardsFaceCameraPosition: 1 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 4 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 2 153 | shadowResolution: 2 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 2 164 | antiAliasing: 2 165 | softParticles: 1 166 | softVegetation: 1 167 | realtimeReflectionProbes: 1 168 | billboardsFaceCameraPosition: 1 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 4 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSM: 5 183 | PSP2: 2 184 | Standalone: 5 185 | Tizen: 2 186 | WebGL: 3 187 | WiiU: 5 188 | Windows Store Apps: 5 189 | XboxOne: 5 190 | iPhone: 2 191 | tvOS: 2 192 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UPRSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!487778994 &1 4 | UPRManager: 5 | m_openweb: 1 6 | m_screenshotEnable: 1 7 | m_objectProfilerTicker: 0 8 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [(English)](README_EN.md) 3 | 4 |
5 | 6 |
7 | 8 | ## **在线示例** 9 | 10 | - **[https://psygames.github.io/UnityWebSocket/](https://psygames.github.io/UnityWebSocket/)** 11 | 12 | 13 | ## **快速开始** 14 | 15 | ### 安装环境 16 | 17 | - Unity 2018.3 或更高版本。 18 | 19 | ### **安装方法** 20 | 21 | - **方式一(推荐):通过 Package Manager 安装** 22 | 23 | 在 Unity 菜单栏中打开 `Window/Package Manager`,点击左上角 `+` 号,选择 `Add package from git URL...` ,输入 `https://github.com/psygames/UnityWebSocket.git#upm` 并确认。 24 | 25 | - **方式二:通过 Unity Package 安装** 26 | 27 | 在 [Releases](https://github.com/psygames/UnityWebSocket/releases) 页面中,下载最新版本的 `UnityWebSocket.unitypackage` 安装包,然后手动导入到您的项目中。 28 | 29 | ### **使用方法** 30 | 31 | - 代码示例 32 | 33 | ```csharp 34 | // 命名空间 35 | using UnityWebSocket; 36 | 37 | // 创建实例 38 | string address = "ws://echo.websocket.org"; 39 | WebSocket socket = new WebSocket(address); 40 | 41 | // 注册回调 42 | socket.OnOpen += OnOpen; 43 | socket.OnClose += OnClose; 44 | socket.OnMessage += OnMessage; 45 | socket.OnError += OnError; 46 | 47 | // 连接 48 | socket.ConnectAsync(); 49 | 50 | // 发送 string 类型数据 51 | socket.SendAsync(str); 52 | 53 | // 或者 发送 byte[] 类型数据(建议使用) 54 | socket.SendAsync(bytes); 55 | 56 | // 关闭连接 57 | socket.CloseAsync(); 58 | ``` 59 | 60 | - 更多使用方法可参考项目中的 [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs) 示例代码。 61 | 62 | - 功能菜单: 63 | - Tools -> UnityWebSocket,版本更新检测,问题反馈渠道等。 64 | 65 | - Unity 编译宏(可选项): 66 | - `UNITY_WEB_SOCKET_LOG` 打开底层日志输出。 67 | 68 | 69 | ### **QQ 交流群** 70 | - 1126457634 >>> [入群通道](https://qm.qq.com/cgi-bin/qm/qr?k=KcexYJ9aYwogFXbj2aN0XHH5b2G7ICmd) <<< 71 | -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | 2 | [(中文版)](README.md) 3 | 4 |
5 | 6 |
7 | 8 | ## **Online Demo** 9 | 10 | - **[https://psygames.github.io/UnityWebSocket/](https://psygames.github.io/UnityWebSocket/)** 11 | 12 | 13 | ## **Quick Start** 14 | 15 | ### **Requirements** 16 | 17 | - Unity 2018.3 or higher. 18 | 19 | ### **Installation** 20 | 21 | - **Install via Package Manager (Recommended)** 22 | 23 | Open Window/Package Manager in the Unity menu bar, click the `+` icon at the top left, select `Add package from git URL...`, enter `https://github.com/psygames/UnityWebSocket.git#upm` and confirm. 24 | 25 | - **Install via Unity Package** 26 | 27 | Download the latest version of `UnityWebSocket.unitypackage` from the [Releases](https://github.com/psygames/UnityWebSocket/releases) page, then import the package into your project. 28 | 29 | ### **Usage** 30 | 31 | - Easy to use 32 | 33 | ```csharp 34 | // the namespace 35 | using UnityWebSocket; 36 | 37 | // create instance 38 | string address = "ws://echo.websocket.org"; 39 | WebSocket socket = new WebSocket(address); 40 | 41 | // register callback 42 | socket.OnOpen += OnOpen; 43 | socket.OnClose += OnClose; 44 | socket.OnMessage += OnMessage; 45 | socket.OnError += OnError; 46 | 47 | // connect 48 | socket.ConnectAsync(); 49 | 50 | // send string data 51 | socket.SendAsync(str); 52 | // or send byte[] data (suggested) 53 | socket.SendAsync(bytes); 54 | 55 | // close connection 56 | socket.CloseAsync(); 57 | ``` 58 | 59 | - For more usage, refer to the [UnityWebSocketDemo.cs](Assets/UnityWebSocket/Demo/UnityWebSocketDemo.cs) example code in the project. 60 | 61 | - Menus 62 | - Tools -> UnityWebSocket, version update check, bug report, etc. 63 | 64 | - Unity Define Symbols(Optional): 65 | - `UNITY_WEB_SOCKET_LOG` Open internal log info. 66 | --------------------------------------------------------------------------------