forked from yasirkula/UnitySimplePatchTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPTUtils.cs
35 lines (30 loc) · 1012 Bytes
/
SPTUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#if UNITY_EDITOR || UNITY_STANDALONE
using SimplePatchToolCore;
using UnityEngine;
namespace SimplePatchToolUnity
{
public class SPTUtils : MonoBehaviour
{
public static SPTUtils Instance { get; private set; }
public delegate void OnUpdateEventHandler();
public event OnUpdateEventHandler OnUpdate;
[RuntimeInitializeOnLoadMethod( RuntimeInitializeLoadType.BeforeSceneLoad )]
private static void Initialize()
{
Instance = new GameObject( "PatcherUtils" ).AddComponent<SPTUtils>();
DontDestroyOnLoad( Instance.gameObject );
}
public static SimplePatchTool CreatePatcher( string rootPath, string versionInfoURL )
{
return new SimplePatchTool( rootPath, versionInfoURL ).
UseCustomDownloadHandler( () => new CookieAwareWebClient() ). // to support https in Unity
UseCustomFreeSpaceCalculator( ( drive ) => long.MaxValue ); // DriveInfo.AvailableFreeSpace is not supported in Unity
}
private void Update()
{
if( OnUpdate != null )
OnUpdate();
}
}
}
#endif