This shows you the differences between two versions of the page.
— |
editorconnection [2021/09/09 22:50] (current) 73.95.178.156 created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== EditorConnection ====== | ||
+ | |||
+ | The '' | ||
+ | |||
+ | ===== Connects fail when using Patch + Run on Android ===== | ||
+ | |||
+ | The port used to connect the player to the editor is stored within the Android data files. These are placed in the '' | ||
+ | |||
+ | When using Patch and Run, only the code changes are installed to the device. However, this can mean the player uses an old port for trying to connect to the editor. The connection won't succeed. | ||
+ | |||
+ | You must either deploy the full obb file to the device, or connect to the player manually using an IP Address. | ||
+ | |||
+ | ===== Android Connections ===== | ||
+ | |||
+ | Normally calling '' | ||
+ | |||
+ | When the player is listening for a connection, you must use an internal method to connect through the localhost proxy connection. For example: | ||
+ | |||
+ | <code csharp> | ||
+ | [Button] | ||
+ | private void ConnectEditorToAndroidPlayer() | ||
+ | { | ||
+ | EditorConnection.instance.Initialize(); | ||
+ | | ||
+ | var connectionResult = -1; | ||
+ | var maxTryCount = 10; | ||
+ | var tryCount = maxTryCount; | ||
+ | while (tryCount-- > 0 && connectionResult == -1) | ||
+ | { | ||
+ | Debug.Log(" | ||
+ | var method = Type.GetType(" | ||
+ | | ||
+ | connectionResult = (int) method.Invoke(null, | ||
+ | { | ||
+ | IPAddress.Loopback.ToString(), | ||
+ | }); | ||
+ | // connectionResult = EditorConnectionInternal.ConnectPlayerProxy(IPAddress.Loopback.ToString(), | ||
+ | // connectionResult = EditorConnectionInternal.ConnectPlayerProxy(IPAddress.Loopback.ToString(), | ||
+ | if (EditorUtility.DisplayCancelableProgressBar(" | ||
+ | 1 - ((float) tryCount / maxTryCount))) | ||
+ | { | ||
+ | EditorUtility.ClearProgressBar(); | ||
+ | throw new Exception(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | EditorUtility.ClearProgressBar(); | ||
+ | if (connectionResult == -1) | ||
+ | throw new Exception( | ||
+ | "Timed out trying to connect to the player. Player failed to launch or crashed soon after launching" | ||
+ | } | ||
+ | </ | ||
+ | |||