Skip to content

dsgarage/UnityRemoteServer

Repository files navigation

Unity Remote Server

Unity License: MIT GitHub release Platform PRs Welcome

A lightweight, zero-configuration HTTP server for Unity Editor that enables remote control and automation through REST APIs. Perfect for CI/CD pipelines, automated testing, and remote development workflows.

✨ Features

  • πŸš€ Zero Configuration - Automatically starts with Unity Editor
  • πŸ”§ Build Automation - Remote builds for iOS, Android, and other platforms
  • πŸ“Š Real-time Log Streaming - Monitor Unity console logs with level filtering
  • πŸ”„ Asset Management - Refresh, reimport, and track compilation status
  • 🎯 Editor Control - Execute menu items and editor operations remotely
  • πŸ”’ Secure by Default - Localhost-only binding for security
  • πŸ“ Extensible API - Easy to add custom endpoints
  • 🧡 Thread-Safe - Proper threading model for Unity's main thread

πŸ“¦ Installation

Option 1: Unity Package Manager (Recommended)

  1. Open Unity Package Manager (Window > Package Manager)
  2. Click "+" β†’ "Add package from git URL"
  3. Enter: https://github.com/dsgarage/UnityRemoteServer.git

Option 2: Download Release

  1. Download the latest .unitypackage from Releases
  2. Import into Unity via Assets > Import Package > Custom Package

Option 3: Manual Installation

cd YourUnityProject/Packages
git clone https://github.com/dsgarage/UnityRemoteServer.git com.dsgarage.unity-remote-server

Option 4: OpenUPM

openupm add com.dsgarage.unity-remote-server

πŸš€ Quick Start

Once installed, the server automatically starts on http://127.0.0.1:8787 when Unity Editor launches.

Test Connection

curl http://127.0.0.1:8787/health
# Response: {"ok":true,"version":"1.0.0"}

πŸ“ Note: Example automation scripts are provided in Examples/Scripts/ directory. These should be used outside your Unity project (in CI/CD pipelines, build servers, etc.)

Basic Usage

# Refresh assets
curl -X POST http://127.0.0.1:8787/refresh \
  -H "Content-Type: application/json" \
  -d '{"force":true}'

# Get compilation errors
curl "http://127.0.0.1:8787/errors?level=error"

# Build for Android
curl -X POST http://127.0.0.1:8787/build \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "android",
    "outputPath": "Builds/game.apk",
    "scenes": ["Assets/Scenes/Main.unity"]
  }'

πŸ“š API Reference

Core Endpoints

Endpoint Method Description
/health GET Server health check
/refresh POST Refresh Unity assets
/awaitCompile POST Wait for compilation to complete
/errors GET Get Unity console logs
/errors/clear POST Clear console logs
/build POST Build project for target platform

Query Parameters

GET /errors

  • level: Filter by log level (error, warning, log, all)
  • limit: Maximum number of entries (default: 200)

Example: /errors?level=error&limit=50

πŸ”§ Configuration

Custom Port

using DSGarage.UnityRemoteServer;

[InitializeOnLoad]
public static class RemoteServerConfig
{
    static RemoteServerConfig()
    {
        RemoteServer.Port = 9090; // Custom port
        RemoteServer.EnableDebugLogging = true;
    }
}

Custom Endpoints

using DSGarage.UnityRemoteServer;

[InitializeOnLoad]
public static class MyCustomEndpoints
{
    static MyCustomEndpoints()
    {
        RemoteServer.RegisterCustomEndpoint("/api/custom", HandleCustomRequest);
    }
    
    static void HandleCustomRequest(HttpListenerContext ctx)
    {
        var response = new { message = "Hello from custom endpoint!" };
        RemoteServer.WriteJson(ctx, 200, JsonUtility.ToJson(response));
    }
}

πŸ“– Documentation

πŸ› οΈ Use Cases

CI/CD Pipeline Integration

# GitHub Actions example
- name: Wait for Unity
  run: |
    until curl -s http://127.0.0.1:8787/health; do sleep 1; done
    
- name: Build Game
  run: |
    curl -X POST http://127.0.0.1:8787/build \
      -H "Content-Type: application/json" \
      -d '{"platform": "android", "outputPath": "build.apk"}'

Automated Testing

// JavaScript test runner example
async function runUnityTests() {
    await fetch('http://127.0.0.1:8787/refresh', { method: 'POST' });
    await fetch('http://127.0.0.1:8787/awaitCompile', { method: 'POST' });
    
    const errors = await fetch('http://127.0.0.1:8787/errors?level=error');
    if (errors.length > 0) {
        throw new Error('Unity has compilation errors');
    }
}

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Unity Technologies for the Unity Editor
  • Contributors and users of this project
  • Open source community

πŸ”— Links

πŸ“Š Stats

GitHub stars GitHub forks GitHub watchers


Made with ❀️ by DS Garage

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •