Repository navigation
Configuration
This guide covers all configuration options for Unity Remote Server.
By default, the server listens on port 8787. You can change this in your Unity Editor script:
using DSGarage.UnityRemoteServer;
using UnityEditor;
[InitializeOnLoad]
public static class CustomServerConfig
{
static CustomServerConfig()
{
RemoteServer.Port = 8080; // Custom port
RemoteServer.EnableDebugLogging = true; // Enable debug logs
}
}For security, the server only binds to localhost (127.0.0.1) by default. This prevents external access.
WARNING: Changing the binding address can expose your Unity Editor to network attacks. Only change this if you understand the security implications.
You can add custom API endpoints to extend functionality:
using DSGarage.UnityRemoteServer;
using UnityEditor;
using System.Net;
[InitializeOnLoad]
public static class CustomEndpoints
{
static CustomEndpoints()
{
// Register custom endpoint
RemoteServer.RegisterCustomEndpoint("/custom/test", HandleCustomTest);
}
static void HandleCustomTest(HttpListenerContext context)
{
// Your custom logic here
var response = new
{
ok = true,
message = "Custom endpoint response",
timestamp = System.DateTime.Now
};
RemoteServer.SendJsonResponse(context, response);
}
}Configure behavior using environment variables:
| Variable | Description | Default |
|---|---|---|
UNITY_REMOTE_PORT |
Server port | 8787 |
UNITY_REMOTE_DEBUG |
Enable debug logging | false |
UNITY_REMOTE_TIMEOUT |
Default timeout (seconds) | 120 |
Example:
export UNITY_REMOTE_PORT=8080
export UNITY_REMOTE_DEBUG=trueConfigure build settings via the API:
{
"platform": "android",
"outputPath": "Builds/game.apk",
"scenes": ["Assets/Scenes/Main.unity"],
"development": false,
"compress": true,
"scriptingBackend": "IL2CPP",
"targetArchitecture": "ARM64"
}-
keystorePath: Path to keystore file -
keystorePassword: Keystore password -
packageName: Application ID -
versionCode: Version code -
splitAPKs: Enable App Bundle
-
teamId: Apple Developer Team ID -
bundleIdentifier: Bundle ID -
provisioningProfile: Profile name -
targetSDK: iOS SDK version
-
architecture: x86 or x64 -
copyPDBFiles: Include debug symbols
Control which logs are captured:
LogStore.MaxEntries = 1000; // Maximum log entries
LogStore.CaptureStackTraces = true; // Include stack traces
LogStore.LogLevels = LogType.Error | LogType.Warning; // Log levels to captureFilter logs by pattern:
LogStore.AddFilter("UnityEngine.*"); // Ignore Unity internal logs
LogStore.AddFilter("System.Reflection.*"); // Ignore reflection logs// Adjust compilation wait behavior
RemoteOps.CompilationCheckInterval = 0.5f; // Check every 500ms
RemoteOps.MaxCompilationWait = 300f; // Maximum 5 minutes// Limit memory usage
LogStore.MaxEntries = 500; // Reduce log buffer
RemoteServer.MaxRequestSize = 10 * 1024 * 1024; // 10MB max requestImplement basic access control:
public class SecurityConfig
{
static HashSet<string> allowedHosts = new HashSet<string>
{
"127.0.0.1",
"localhost"
};
public static bool IsAllowed(HttpListenerContext context)
{
var host = context.Request.RemoteEndPoint.Address.ToString();
return allowedHosts.Contains(host);
}
}Validate incoming requests:
RemoteServer.RegisterRequestValidator((context) =>
{
// Check custom headers
var apiKey = context.Request.Headers["X-API-Key"];
return apiKey == "your-secret-key";
});If port 8787 is already in use:
- Change the port in configuration
- Or find and stop the conflicting process:
# Find process using port 8787
lsof -i :8787 # macOS/Linux
netstat -ano | findstr :8787 # Windows
# Kill the process
kill -9 <PID> # macOS/Linux
taskkill /PID <PID> /F # WindowsEnsure your configuration script:
- Is in an Editor folder
- Has
[InitializeOnLoad]attribute - Has a static constructor
Enable verbose logging:
RemoteServer.EnableDebugLogging = true;
Debug.Log($"Server running on port: {RemoteServer.Port}");
Debug.Log($"Custom endpoints: {RemoteServer.GetCustomEndpoints().Count}");Create remote-server.json in your project root:
{
"server": {
"port": 8787,
"debugLogging": false,
"timeout": 120
},
"build": {
"defaultPlatform": "android",
"outputDirectory": "Builds",
"development": false
},
"logging": {
"maxEntries": 1000,
"captureStackTraces": true,
"levels": ["error", "warning"]
}
}Load configuration:
[InitializeOnLoad]
public static class ConfigLoader
{
static ConfigLoader()
{
var configPath = "remote-server.json";
if (File.Exists(configPath))
{
var json = File.ReadAllText(configPath);
var config = JsonUtility.FromJson<ServerConfig>(json);
ApplyConfiguration(config);
}
}
}