{"id":27957503,"url":"https://github.com/radish2951/unityvelopacklauncher","last_synced_at":"2025-05-07T18:13:21.496Z","repository":{"id":291810493,"uuid":"978845123","full_name":"radish2951/UnityVelopackLauncher","owner":"radish2951","description":"Integrates Velopack auto-updates into Unity applications via a custom C# launcher.","archived":false,"fork":false,"pushed_at":"2025-05-06T20:31:06.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T18:13:16.843Z","etag":null,"topics":["csharp","unity","velopack"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/radish2951.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-06T15:40:13.000Z","updated_at":"2025-05-06T20:31:10.000Z","dependencies_parsed_at":"2025-05-06T17:29:03.762Z","dependency_job_id":"6d5cb8c8-1424-4024-a058-3e32d7bba585","html_url":"https://github.com/radish2951/UnityVelopackLauncher","commit_stats":null,"previous_names":["radish2951/unityvelopacklauncher"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radish2951%2FUnityVelopackLauncher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radish2951%2FUnityVelopackLauncher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radish2951%2FUnityVelopackLauncher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radish2951%2FUnityVelopackLauncher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/radish2951","download_url":"https://codeload.github.com/radish2951/UnityVelopackLauncher/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931550,"owners_count":21827112,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","unity","velopack"],"created_at":"2025-05-07T18:13:20.749Z","updated_at":"2025-05-07T18:13:21.487Z","avatar_url":"https://github.com/radish2951.png","language":"C#","readme":"# Unity Velopack Launcher\n\nA template project to create a custom launcher for Unity applications, enabling self-updating capabilities through [Velopack](https://velopack.io/). This launcher dynamically loads `UnityPlayer.dll` and calls the `UnityMain` function. Crucially, it initializes Velopack **before** the Unity engine starts, which is a necessary step for Velopack to function correctly with Unity.\n\nThis project provides the **minimum C# launcher code** required to get Velopack initialized in a way that's compatible with a standard Unity build. The actual update checking, downloading, and applying logic within your Unity application needs to be implemented by you, leveraging the Velopack C# API.\n\n**🚀 Super detailed explanations are available at [DeepWiki](https://deepwiki.com/radish2951/UnityVelopackLauncher)! It's fantastic! 🚀**\n\n## Features\n\n*   Integrates Velopack initialization into a standalone C# launcher, executed before Unity starts.\n*   Dynamically loads and runs your Unity application.\n*   Provides the foundation for your Unity application to use Velopack APIs.\n*   Acts as a template for building a custom launcher tailored to your Unity project.\n\n## Prerequisites\n\n*   **.NET SDK:** You need the .NET SDK (version 8.0 or later recommended) installed on your development machine to build the launcher. You can download it from [here](https://dotnet.microsoft.com/download).\n*   **Unity Project:** A built Unity application (Windows x64, using the Mono scripting backend is generally recommended for easier `System.Diagnostics.Process` API usage if needed by Velopack or your update logic. See Velopack's Unity documentation for IL2CPP considerations).\n\n## How to Use\n\n1.  **Clone or Download:**\n    *   Clone this repository or download it as a ZIP.\n    *   `git clone https://github.com/radish2951/UnityVelopackLauncher.git`\n\n2.  **Customize Project Settings:**\n    *   Open `Launcher.csproj` in a text editor or IDE.\n    *   Update the following placeholder properties with your application's information:\n        *   `\u003cAssemblyName\u003eYourProductName\u003c/AssemblyName\u003e` (e.g., `MyAwesomeGame`)\n        *   `\u003cCompany\u003eYourCompanyName\u003c/Company\u003e`\n        *   `\u003cProduct\u003eYourProductName\u003c/Product\u003e` (e.g., `My Awesome Game`)\n        *   `\u003cDescription\u003eYour product description here\u003c/Description\u003e`\n        *   `\u003cCopyright\u003eCopyright (C) 2025 YourCompanyName\u003c/Copyright\u003e`\n    *   Open `Launcher.manifest`.\n    *   Update the following placeholders:\n        *   `\u003cassemblyIdentity name=\"YourCompany.YourAwesomeGame.Launcher\" ... /\u003e` (e.g., `MyCompany.MyAwesomeGame.Launcher`)\n        *   `\u003cdescription\u003eYour application description here\u003c/description\u003e`\n    *   Replace `Launcher.ico` with your application's icon file. Ensure it's named `Launcher.ico` or update the `\u003cApplicationIcon\u003e` tag in `Launcher.csproj` accordingly.\n\n3.  **Install Velopack Package:**\n    *   Open a terminal or command prompt in the `UnityVelopackLauncher` directory (where `Launcher.csproj` is located).\n    *   Run the following command to add the Velopack NuGet package to the project:\n        ```bash\n        dotnet add package Velopack\n        ```\n        This ensures the necessary Velopack libraries are included for the launcher.\n\n4.  **Build the Launcher:**\n    *   Open a terminal or command prompt in the `UnityVelopackLauncher` directory.\n    *   Run the publish command to create a single, self-contained executable:\n        ```bash\n        dotnet publish Launcher.csproj -c Release -r win-x64 --self-contained true /p:PublishSingleFile=true\n        ```\n        *   `-c Release`: Builds in Release configuration.\n        *   `-r win-x64`: Targets Windows x64.\n        *   `--self-contained true`: Includes the .NET runtime with the executable.\n        *   `/p:PublishSingleFile=true`: Creates a single executable file.\n\n    *   The published executable will be located in a subfolder within `bin/Release/net8.0-windows/win-x64/publish/`. For example:\n        `UnityVelopackLauncher/bin/Release/net8.0-windows/win-x64/publish/YourProductName.exe` (The name will be what you set in `\u003cAssemblyName\u003e`).\n\n5.  **Integrate with Your Unity Build:**\n    *   Build your Unity project for Windows x64 as usual.\n    *   Navigate to your Unity build's output directory (e.g., `Build/`).\n    *   You will find your original Unity executable (e.g., `MyUnityGame.exe`) and a `*_Data` folder (e.g., `MyUnityGame_Data/`).\n    *   **Replace the original Unity executable** (e.g., `MyUnityGame.exe`) with the launcher executable you built in step 4 (e.g., `YourProductName.exe`). Make sure to rename your built launcher to match the original Unity executable's name.\n    *   Ensure `UnityPlayer.dll` is in the same directory as your new launcher executable. The launcher expects `UnityPlayer.dll` to be in its immediate vicinity.\n\n6.  **Leverage Velopack in Your Unity Application (optionally):**\n    *   This launcher (`Launcher.cs`) performs the crucial step of initializing Velopack via `VelopackApp.Build().Run()` **before** your Unity application starts. This is the primary function of this template.\n    *   **With Velopack initialized by this launcher, your Unity application is now ready to utilize any of Velopack's features.**\n    *   For example, you can:\n        *   Use the `vpk` command-line tool to create installers and releases for your application.\n        *   Implement in-app update checking and application logic using Velopack's C# API from your Unity scripts.\n    *   How you choose to use Velopack beyond this initial setup is up to your project's needs.\n    *   **For detailed guidance on using Velopack's C# API, creating packages, implementing update logic, and other features, please refer to the official Velopack documentation and their Unity sample project.** See the [References](#references) section below for direct links.\n\n## Project Structure\n\n```\nUnityVelopackLauncher/\n├── Launcher.cs # Main launcher code (C#) - Handles Velopack init and Unity launch\n├── Launcher.csproj # C# project file\n├── Launcher.manifest # Application manifest for Windows\n├── Launcher.ico # Application icon\n├── LICENSE # Project license\n└── README.md # This file\n```\n\n## How it Works\n\n1.  The `Main` method in `Launcher.cs` is the entry point.\n2.  `VelopackApp.Build().Run()`: Initializes Velopack. This is the **key step** provided by this launcher. It handles Velopack's startup tasks, including checking for pending updates from a previous run and applying them if necessary. If an update was just applied and a restart is needed, Velopack handles it before your custom Unity launch code is executed.\n3.  If no update-related restart by Velopack occurs, the launcher proceeds to:\n    *   Load `UnityPlayer.dll` from the same directory.\n    *   Get the address of the `UnityMain` function within `UnityPlayer.dll`.\n    *   Call `UnityMain` to start the Unity engine, passing necessary arguments.\n4.  Your Unity application then runs. It is now **your responsibility** to implement the logic using Velopack's C# API (e.g., `UpdateManager`) to check for new updates, download them, and trigger the update process (e.g., via `updateManager.WaitExitThenApplyUpdates(...)` followed by `UnityEngine.Application.Quit()`).\n5.  Error handling is in place in the launcher to display messages if `UnityPlayer.dll` cannot be loaded or `UnityMain` cannot be found.\n\n## References\n\nFor more detailed information on Velopack, Unity integration, and the Windows build process, please refer to the following resources:\n\n*   **Velopack Documentation:**\n    *   [Getting Started with .NET (Velopack C# API)](https://docs.velopack.io/getting-started/csharp) - Official guide for using Velopack with .NET applications.\n    *   [Velopack App Hooks](https://docs.velopack.io/integrating/hooks) - Understanding how Velopack integrates with application startup.\n*   **Velopack Unity Sample:**\n    *   [CSharpUnityMono Sample (GitHub)](https://github.com/velopack/velopack/tree/develop/samples/CSharpUnityMono) - A sample project demonstrating Velopack integration with a Unity (Mono backend) application. This is a key resource for understanding how to implement update logic within Unity.\n*   **Unity Documentation:**\n    *   [Windows Player build binaries (Unity Manual)](https://docs.unity3d.com/Manual/WindowsStandaloneBinaries.html) - Official Unity documentation explaining the files generated during a Windows build and how `UnityPlayer.dll` is structured. This also touches upon rebuilding the executable.\n    *   [Unity Standalone Player command line arguments](https://docs.unity3d.com/Manual/PlayerCommandLineArguments.html) - Useful if you need to pass custom arguments to `UnityMain` via this launcher.\n    *   [Scripting restrictions in IL2CPP (Unity Manual)](https://docs.unity3d.com/Manual/scripting-restrictions.html) - Important considerations if you are targeting IL2CPP, especially regarding `System.Diagnostics.Process`.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue or DM [@radish2951](https://x.com/radish2951).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradish2951%2Funityvelopacklauncher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradish2951%2Funityvelopacklauncher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradish2951%2Funityvelopacklauncher/lists"}