| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This project integrates Velopack into unity by way of a nuget for Unity package.
Currently, Velopack is only support for Unity mono runtime, it does not support for IL2CPP, due to the following reasons:
https://docs.unity3d.com/2022.3/Documentation/Manual/ScriptingRestrictions.html
IL2CPP doesn’t support the System.Diagnostics.Process API methods. For cases where this is required on desktop platforms, use the Mono scripting backend.
If you still want to use Velopack in IL2CPP, you can use the following workaround
(remember that this is not recommended and may change in the future):
static VelopackRuntimeInfo()
{
//delete the following line
//EntryExePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
EntryExePath = Application.dataPath;
if (!Application.isEditor)
{
EntryExePath = Path.Combine(EntryExePath, "..", Application.productName + ".exe");
}
}The first build is to generate the normal Unity project.
The second build is to generate the .exe file that Velopack needs to pack. Since the Unity executable on Windows is packaged in C++, its process needs some modification to integrate Velopack's App Hooks. you can see the following code in the Main.cpp file
#include "PrecompiledHeader.h"
#include "..\UnityPlayerStub\Exports.h"
//for Velopack
#include "..\Velopack.hpp"
#include "Windows.h"
#include <shellapi.h>
//for Velopack
// Hint that the discrete gpu should be enabled on optimus/enduro systems
// NVIDIA docs: http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
// AMD forum post: http://devgurus.amd.com/thread/169965
extern "C"
{
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
{
//for Velopack
int pNumArgs = 0;
wchar_t** args = CommandLineToArgvW(lpCmdLine, &pNumArgs);
Velopack::startup(args, pNumArgs);
//for Velopack
return UnityMain(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
}
Do not use ApplyUpdatesAndExit because Environment.Exit is not supported. Instead, use the following to apply update:
updateManager.WaitExitThenApplyUpdates(...);
UnityEngine.Application.Quit();This will work because WaitExitThenApplyUpdates will not call Environment.Exit, but it will prepare up the Velopack updater to install the update when unity closes.
| Back | FazBrowse Home | New Git URL |