Compare commits
417 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aebe27cfea | |||
| 8155e6bc3d | |||
| 492040d382 | |||
| e14a683f62 | |||
| d754ff3b15 | |||
| 1bd1ffdb5a | |||
| c50c229e30 | |||
| 50b46c5b76 | |||
| 8e88b4adba | |||
| 609e4dc367 | |||
| 9a545f00f4 | |||
| baab5a9fb0 | |||
| e8a12452ca | |||
| f92b623349 | |||
| a9fc25defb | |||
| 558fb16160 | |||
| b9aa0131cc | |||
| eb21914fb7 | |||
| a4e17a56d0 | |||
| e503443f22 | |||
| 3a834fca08 | |||
| 8f8ee0b833 | |||
| 26e4e81402 | |||
| b075279a14 | |||
| f731494396 | |||
| dd4157cbc2 | |||
| 05f6c8a08b | |||
| 3c540dece4 | |||
| d8adb8a5b8 | |||
| 9be2e77ae5 | |||
| 0560d0f278 | |||
| efd1795e63 | |||
| 4d404b9162 | |||
| f0314adb27 | |||
| 2f0291836e | |||
| d4326ffb42 | |||
| 44ff898f8d | |||
| f3da1a5575 | |||
| c19b8630cf | |||
| 55d7304de1 | |||
| f1ddde8a2e | |||
| cad2e92fd2 | |||
| 4aa6178495 | |||
| fd8f419f09 | |||
| 6d1bc8e2c8 | |||
| d035361718 | |||
| 6501284bbc | |||
| 9511e30e50 | |||
| 561ad993b8 | |||
| 8d8fd59a80 | |||
| b74c3b57b4 | |||
| 85e0a13f08 | |||
| 8802676b98 | |||
| 486b385c84 | |||
| 5bd1c3b1ca | |||
| c73545d912 | |||
| 75900ccf3d | |||
| 65e7d9c4f4 | |||
| 1c73701e73 | |||
| 125e9a48c6 | |||
| 9eab7c847b | |||
| f35dea5c6a | |||
| 18b330fa30 | |||
| 211967dda2 | |||
| edf0313155 | |||
| 62e88668e0 | |||
| b89322c59b | |||
| a67602b00b | |||
| 65f2b0af0a | |||
| 40b6205abc | |||
| 9b0c86aefb | |||
| e6e519d166 | |||
| 750d9107b4 | |||
| 26250f3e47 | |||
| a999bf1b72 | |||
| 806116af19 | |||
| 58fe43d59f | |||
| 27881fbb6b | |||
| 8fde11f985 | |||
| bd8089d0a9 | |||
| 1b7e585027 | |||
| d7486c920c | |||
| 8c7a9afaa3 | |||
| 49c264ff36 | |||
| 6640780c93 | |||
| b5c78aba4f | |||
| 7d4617eca6 | |||
| 48397f3d1d | |||
| ad26419654 | |||
| 15015f83a8 | |||
| 6fa4504e46 | |||
| afb8c358f5 | |||
| 0b1247249d | |||
| 7bd058004d | |||
| e84f14250b | |||
| ae6769e24f | |||
| 939d6f1d0c | |||
| dfb80658dd | |||
| 969835e4d7 | |||
| 51cea743be | |||
| ca51e06d37 | |||
| ee1114e2cf | |||
| f1f982b90c | |||
| 50ad74bb09 | |||
| 5a148c28a8 | |||
| 8a4657c11c | |||
| b86cb01ea2 | |||
| 99081519bb | |||
| fe65b83c89 | |||
| 510cd11049 | |||
| b11c5de681 | |||
| 467a6f3810 | |||
| 169b9719f6 | |||
| 1254414415 | |||
| 7af935118e | |||
| 3fb8aee922 | |||
| c280408192 | |||
| c5586b3eb1 | |||
| 2663068574 | |||
| 3ec6fd0569 | |||
| cdccd78602 | |||
| 3a360d3437 | |||
| 29aef943b9 | |||
| 99540eb1fd | |||
| 85130ce6c3 | |||
| 428a7c5507 | |||
| d8927ceca5 | |||
| f21b83697b | |||
| 723c881790 | |||
| e1a85eeb5e | |||
| 0139cbc173 | |||
| eb87fe07aa | |||
| 89e3a04fe9 | |||
| 92c8f246b8 | |||
| bb08b6b762 | |||
| 88beff5b89 | |||
| f155b2b627 | |||
| 341195d78d | |||
| 3de8b1d555 | |||
| 3c9d489c76 | |||
| 31e8e3bebb | |||
| d6c3ea2007 | |||
| 6fab61f97d | |||
| f6740d31bb | |||
| 81a18de9f4 | |||
| ca91f45ef3 | |||
| f14a071179 | |||
| 688c12b28e | |||
| f39500c560 | |||
| 34a2c0bbb2 | |||
| dd669d74f5 | |||
| a6f673f805 | |||
| 49da1493d5 | |||
| 35b5ab59d3 | |||
| 11e9acdb14 | |||
| 906dc7dec8 | |||
| 3902865658 | |||
| 32b6e28736 | |||
| 25dcf0fde3 | |||
| c91bf7ae2f | |||
| a9530096e4 | |||
| bb8a0712b7 | |||
| 570bd1554f | |||
| 3fcc6c0489 | |||
| c717b93169 | |||
| 5642d3f1c9 | |||
| 81a7af517a | |||
| 40bb16a132 | |||
| 7a1042d184 | |||
| 9f19e951cc | |||
| 317f7c6d8c | |||
| 8b5070214e | |||
| fe2c0280dc | |||
| b8a5982bc5 | |||
| da4fed58b0 | |||
| ea70e04ec0 | |||
| be677e766d | |||
| 07a7a95aa8 | |||
| 074200cb4f | |||
| b4e97d5514 | |||
| bea0e40ec1 | |||
| 12838266ba | |||
| 44c1b771f7 | |||
| 3c6edc624b | |||
| 1919370a23 | |||
| 9ab8165630 | |||
| 7884e7ac7e | |||
| 50fd9c3af6 | |||
| 33df128750 | |||
| edce9c676d | |||
| 6ab3ee19f2 | |||
| b9db3325a8 | |||
| b8ffdcbffe | |||
| 09f72d10bd | |||
| 5c96b10385 | |||
| 7d0a4fbd97 | |||
| c96cdbb163 | |||
| abf913b467 | |||
| 978debcd23 | |||
| 4a8239a2db | |||
| 952e5038ed | |||
| 3307d96ff3 | |||
| ea717ccdb8 | |||
| e29f0a8116 | |||
| cfcb302a31 | |||
| 0eb399be9a | |||
| ca938ab6f5 | |||
| ea79b6cfc5 | |||
| c9b5520331 | |||
| 164db7c013 | |||
| d4ae01cd32 | |||
| 17f2b1cedd | |||
| ab9b6a86f3 | |||
| 7d0128d912 | |||
| 1f3485846f | |||
| 929fb0a1a7 | |||
| ac59808915 | |||
| 7f8ac10d47 | |||
| b93fbd2f2e | |||
| ae3f9d2101 | |||
| 21529db9dc | |||
| 1c2afb4125 | |||
| d18ff09002 | |||
| d9d66ab96c | |||
| e76b5c443f | |||
| eed2d13624 | |||
| eb1803c9ef | |||
| b2a527f518 | |||
| d6a7cd798f | |||
| ec45246aa4 | |||
| 380e67cc1e | |||
| 58ec860669 | |||
| 858b76d4d2 | |||
| 2f8318b24e | |||
| 23d049d176 | |||
| 6ad01c50df | |||
| dcc65cdd86 | |||
| 3f718f1490 | |||
| ebe3dc11e6 | |||
| 8dfd4d696c | |||
| 734893ff83 | |||
| dd474f1f61 | |||
| 936d325cf9 | |||
| 5f7cc43593 | |||
| 15e440715d | |||
| abd35810bc | |||
| 5ec6f4caca | |||
| 25c866d090 | |||
| 4064d4294a | |||
| 541aefe4dd | |||
| 1020632757 | |||
| 35b50efded | |||
| aa75bb281f | |||
| b6d70e6856 | |||
| 432e02e3de | |||
| 17eaccb72e | |||
| 5671b35dce | |||
| 7729332f41 | |||
| 2f84f70a5f | |||
| 84e8b50bbf | |||
| 8e1b4bbbca | |||
| e88f32e99b | |||
| 4e4da38252 | |||
| 3757ae6e6c | |||
| a2a6ee1f49 | |||
| 724e43f392 | |||
| 5599d6dcc8 | |||
| 509a7c16bd | |||
| 7eb76291ec | |||
| 0517382612 | |||
| fdf33ba8df | |||
| 2d36d5df39 | |||
| 5db375bcf5 | |||
| 3e38fd65c2 | |||
| 7ba012f5f2 | |||
| 09514e2a8a | |||
| f1eeb11543 | |||
| 470d52b1bc | |||
| eb70ee4397 | |||
| e29381b13b | |||
| 46cc231fe7 | |||
| b694a69f16 | |||
| 87d581291b | |||
| 53ec9c60ac | |||
| a7ea02f70a | |||
| 8f0598580d | |||
| 2c5501a096 | |||
| 2b4b2c4f70 | |||
| 8ca32cd1ae | |||
| 6645310601 | |||
| 696fd256a8 | |||
| 92676d7cf8 | |||
| 9a4e646a8f | |||
| d4339968f6 | |||
| 584cba79ae | |||
| 60bf5bd59d | |||
| e4d4333357 | |||
| 9bc3864790 | |||
| 39d84e2e8a | |||
| 6b380b3442 | |||
| 3ec804f1b0 | |||
| d96721e826 | |||
| 071a0e1170 | |||
| 392eca5dc2 | |||
| af34243c28 | |||
| 9f4e446850 | |||
| 6399c26f7e | |||
| f6a4ebda8c | |||
| 333542a63a | |||
| 2b6be4711c | |||
| 48c5b161b1 | |||
| f7b33bf491 | |||
| cb93e31143 | |||
| 52fd841486 | |||
| aaef57c0b0 | |||
| b030294bd6 | |||
| 82997480fe | |||
| 44abc5ded1 | |||
| 7b4fbc513e | |||
| 8eb201d0ee | |||
| a49acaab1e | |||
| 540bbc9a7c | |||
| de61fbd291 | |||
| ae55258b9b | |||
| 4cb40f2c8e | |||
| b15a4fe2c1 | |||
| 9993752ff5 | |||
| 614d067d25 | |||
| 6d45d052a0 | |||
| 3b63dec2e1 | |||
| c8111d7db3 | |||
| b71a15e2ba | |||
| 00b9c7e796 | |||
| 5080503ebd | |||
| 86a5b68317 | |||
| 8226b8a7c2 | |||
| 4353a38c96 | |||
| 1002b0433a | |||
| 2b275d6dc5 | |||
| 02b8f97d83 | |||
| 8de7e94c8d | |||
| bbc3deeef2 | |||
| 0f8af223fc | |||
| 048538a0c8 | |||
| 9ac7c86ca6 | |||
| 11fdcff7c3 | |||
| 922f66bb75 | |||
| a96d538dc1 | |||
| d35c9daa82 | |||
| 4347a8eeba | |||
| dd08f916eb | |||
| 96f3644b5b | |||
| 40d118cea3 | |||
| e7ad9473a5 | |||
| 1c712ff7d5 | |||
| bb4fabc833 | |||
| 4896fab824 | |||
| f10eeac073 | |||
| 2d20edf57a | |||
| 82923fe4f8 | |||
| 51c6fd7236 | |||
| af63072f29 | |||
| afba150d91 | |||
| f065bf4bbb | |||
| 19766db051 | |||
| 0346b650aa | |||
| 018699c944 | |||
| 10c82703f4 | |||
| 70626ae741 | |||
| 92e43c2cd8 | |||
| f4cbad819b | |||
| c97bd50f3f | |||
| e04ae0b085 | |||
| 62938ec6ae | |||
| 7744eec847 | |||
| 038720e7bd | |||
| d22eecd133 | |||
| 10e738f958 | |||
| 34cde86a28 | |||
| 2fcd9b23fa | |||
| 5156473bb2 | |||
| 07feba912c | |||
| 725b510748 | |||
| 65fc5b5c50 | |||
| e7a3214cb5 | |||
| ae9cefc645 | |||
| ec7589096f | |||
| 2e6338bcf3 | |||
| 996f924719 | |||
| eb93577d68 | |||
| b0f6c39118 | |||
| 8638cd97de | |||
| dad88828d2 | |||
| 9a7830f46a | |||
| d5133ee7b0 | |||
| 8ad36c965d | |||
| 42fa59d103 | |||
| 0ab0e99597 | |||
| 971a6f7e0e | |||
| 326b74bd03 | |||
| 3c2bb10f07 | |||
| f45711f39f | |||
| db3fc6ee83 | |||
| d1d9c92f1c | |||
| cbc79df8a2 | |||
| 38d1c387c3 | |||
| c5bd9daba2 | |||
| e7044b3cde | |||
| ba324aa68d | |||
| ba994e715c | |||
| b7cc1653f4 | |||
| 6f7c4e78bd | |||
| 4ecf26ec80 | |||
| 45801dff22 | |||
| 60d12fcab2 | |||
| 398628017c | |||
| f557e2f5df |
23
.gitignore
vendored
23
.gitignore
vendored
@ -69,3 +69,26 @@ crashlytics-build.properties
|
||||
# Temporary auto-generated Android Assets
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa.meta
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa/*
|
||||
Assets/Packages
|
||||
Assets/Packages.meta
|
||||
Assets/Shader2D-master
|
||||
Assets/ZFBrowser
|
||||
Assets/Resources/UI/Font/*.ttf
|
||||
Assets/WorldPoliticalMapGlobeEdition
|
||||
Assets/WorldPoliticalMapGlobeEdition.meta
|
||||
Assets/earth
|
||||
Assets/Chart And Graph
|
||||
Assets/NuGet
|
||||
Assets/NuGet.meta
|
||||
Assets/earth.meta
|
||||
Assets/MapWorkoutRecords.meta
|
||||
Assets/Devices.txt
|
||||
Assets/Devices.txt.meta
|
||||
Assets/StreamingAssets.meta
|
||||
Assets/Resources/Sound.meta
|
||||
Assets/MapWorkoutRecords
|
||||
Assets/Mapbox/User
|
||||
Assets/Mapbox/User.meta
|
||||
Packages/packages-lock.json
|
||||
GPUCache
|
||||
Assets/Shatalmic/plugin.unitypackage.meta
|
||||
|
||||
6
.vsconfig
Normal file
6
.vsconfig
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
||||
130
Assets/AndroidUpdate.cs
Normal file
130
Assets/AndroidUpdate.cs
Normal file
@ -0,0 +1,130 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AndroidUpdate : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
JObject data { get; set; }
|
||||
public void StartDownload(JObject jo)
|
||||
{
|
||||
transform.Find("Panel/CurrentVersion").GetComponent<Text>().text = $"Current Version: {App.AppVersion}";
|
||||
transform.Find("Panel/LastestVersion").GetComponent<Text>().text = $"Latest Version: {jo.Value<string>("Version")}";
|
||||
data = jo;
|
||||
var path = Application.temporaryCachePath + "/PowerFun.apk";
|
||||
StartCoroutine(DownLoadExe(data.Value<string>("Url"), path, (p, isComplete) =>
|
||||
{
|
||||
transform.Find("Panel/Size").GetComponent<Text>().text = $"Downloaded {Math.Round(p * 100, 0)}%";// string.Format(, a, b);
|
||||
transform.Find("Panel/Progress").GetComponent<Image>().fillAmount = (float)p;
|
||||
if (isComplete)
|
||||
{
|
||||
PlayerPrefs.SetString("exeVersion", data.Value<string>("Version"));
|
||||
new FileInfo(path + ".pfdownload").MoveTo(path);
|
||||
OpenApk(path);
|
||||
//Application.Quit();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/*下载文件*/
|
||||
IEnumerator DownLoadExe(string url, string desFileName, Action<double, bool> OnDownloadProgressEvent)
|
||||
{
|
||||
string version = data.Value<string>("Version");
|
||||
if (File.Exists(desFileName))
|
||||
{
|
||||
//if(PlayerPrefs.GetString("exeVersion")==)
|
||||
if (version == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version == PlayerPrefs.GetString("exeVersion"))
|
||||
{
|
||||
OpenApk(desFileName);
|
||||
//Application.Quit();
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(desFileName);
|
||||
}
|
||||
}
|
||||
|
||||
//File.Delete(desFileName);
|
||||
}
|
||||
if (File.Exists(desFileName + ".pfdownload"))
|
||||
{
|
||||
File.Delete(desFileName + ".pfdownload");
|
||||
}
|
||||
|
||||
using (var uwr = UnityWebRequest.Get(url))
|
||||
{
|
||||
var operation = uwr.SendWebRequest();
|
||||
|
||||
while (!operation.isDone)
|
||||
{
|
||||
/*
|
||||
* as BugFinder metnioned in the comments
|
||||
* what you want to track is uwr.downloadProgress
|
||||
*/
|
||||
var downloadDataProgress = uwr.downloadProgress * 100;
|
||||
|
||||
/*
|
||||
* use a float division here
|
||||
* I don't know what type downloadDataProgress is
|
||||
* but if it is an int than you will always get
|
||||
* an int division <somethingSmallerThan100>/100 = 0
|
||||
*/
|
||||
//progressBar.fillAmount = downloadDataProgress / 100.0f;
|
||||
OnDownloadProgressEvent.Invoke(uwr.downloadProgress, false);
|
||||
Debug.Log("Download: " + downloadDataProgress);
|
||||
yield return null;
|
||||
}
|
||||
ByteArrayToFile(desFileName + ".pfdownload", uwr.downloadHandler.data);
|
||||
OnDownloadProgressEvent.Invoke(1, true);
|
||||
}
|
||||
}
|
||||
bool ByteArrayToFile(string fileName, byte[] byteArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
fs.Write(byteArray, 0, byteArray.Length);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenApk(string path)
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
var activity = jc.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
//Debug.Log("打开apk"+ "file://" + path);
|
||||
activity.Call("OpenApk", path);
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/AndroidUpdate.cs.meta
Normal file
11
Assets/AndroidUpdate.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef1001f46abd4064a9837992f252bb97
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/AppCenter.meta
Normal file
8
Assets/AppCenter.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3924cc2cd3f083b4b89f4ade5ab4137f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
200
Assets/AppCenter/AppCenterBehavior.cs
Normal file
200
Assets/AppCenter/AppCenterBehavior.cs
Normal file
@ -0,0 +1,200 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.AppCenter.Unity;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.AppCenter.Unity.Internal;
|
||||
using System.Linq;
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
|
||||
[HelpURL("https://docs.microsoft.com/en-us/appcenter/sdk/crashes/unity")]
|
||||
public class AppCenterBehavior : MonoBehaviour
|
||||
{
|
||||
public static event Action InitializingServices;
|
||||
public static event Action InitializedAppCenterAndServices;
|
||||
public static event Action Started;
|
||||
|
||||
private static AppCenterBehavior _instance;
|
||||
|
||||
public AppCenterSettings Settings;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Make sure that App Center have only one instance.
|
||||
if (_instance != null)
|
||||
{
|
||||
Debug.LogError("App Center Behavior should have only one instance!");
|
||||
DestroyImmediate(gameObject);
|
||||
return;
|
||||
}
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
#if UNITY_WSA_10_0
|
||||
StartAppCenter();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
#if !UNITY_WSA_10_0
|
||||
StartAppCenter();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void Reset()
|
||||
{
|
||||
if (FindObjectsOfType<AppCenterBehavior>().Length > 1)
|
||||
{
|
||||
Debug.LogError("Only one game object with App Center Behaviour should exist.");
|
||||
DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void StartAppCenter()
|
||||
{
|
||||
if (Settings == null)
|
||||
{
|
||||
Debug.LogError("App Center isn't configured!");
|
||||
return;
|
||||
}
|
||||
var services = Settings.Services;
|
||||
PrepareEventHandlers(services);
|
||||
InvokeInitializingServices();
|
||||
AppCenter.SetWrapperSdk();
|
||||
AppCenter.CacheStorageSize(Settings.MaxStorageSize.Size);
|
||||
if (Settings.CustomLogUrl.UseCustomUrl)
|
||||
{
|
||||
AppCenter.CacheLogUrl(Settings.CustomLogUrl.Url);
|
||||
}
|
||||
var appSecret = AppCenter.ParseAndSaveSecretForPlatform(Settings.AppSecret);
|
||||
var advancedSettings = GetComponent<AppCenterBehaviorAdvanced>();
|
||||
AppCenter.NetworkRequestsAllowed = Settings.AllowNetworkRequests;
|
||||
if (IsStartFromAppCenterBehavior(advancedSettings))
|
||||
{
|
||||
AppCenter.LogLevel = Settings.InitialLogLevel;
|
||||
if (Settings.CustomLogUrl.UseCustomUrl)
|
||||
{
|
||||
AppCenter.SetLogUrl(Settings.CustomLogUrl.Url);
|
||||
}
|
||||
if (Settings.MaxStorageSize.UseCustomMaxStorageSize && Settings.MaxStorageSize.Size > 0)
|
||||
{
|
||||
AppCenterInternal.SetMaxStorageSize(Settings.MaxStorageSize.Size);
|
||||
}
|
||||
var startupType = GetStartupType(advancedSettings);
|
||||
if (startupType != StartupType.Skip)
|
||||
{
|
||||
var transmissionTargetToken = GetTransmissionTargetToken(advancedSettings);
|
||||
var appSecretString = GetAppSecretString(appSecret, transmissionTargetToken, startupType);
|
||||
if (string.IsNullOrEmpty(appSecretString))
|
||||
{
|
||||
AppCenterInternal.Start(services);
|
||||
}
|
||||
else
|
||||
{
|
||||
AppCenterInternal.Start(appSecretString, services);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
else
|
||||
{
|
||||
foreach (var service in services)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
// On iOS and Android we start crash service here, to give app an opportunity to assign handlers after crash and restart in Awake method
|
||||
var startCrashes = service.GetMethod("StartCrashes");
|
||||
if (startCrashes != null)
|
||||
startCrashes.Invoke(null, null);
|
||||
|
||||
// On iOS and Android we start distribute service here, to give app an opportunity to assign handlers after distribute and restart in Awake method
|
||||
var startDistribute = service.GetMethod("StartDistribute");
|
||||
if (startDistribute != null)
|
||||
startDistribute.Invoke(null, null);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
InvokeInitializedServices();
|
||||
if (Started != null)
|
||||
{
|
||||
Started.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsStartFromAppCenterBehavior(AppCenterBehaviorAdvanced advancedSettings)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
return advancedSettings != null && advancedSettings.SettingsAdvanced != null && advancedSettings.SettingsAdvanced.StartIOSNativeSDKFromAppCenterBehavior;
|
||||
#elif UNITY_ANDROID
|
||||
return advancedSettings != null && advancedSettings.SettingsAdvanced != null && advancedSettings.SettingsAdvanced.StartAndroidNativeSDKFromAppCenterBehavior;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
private StartupType GetStartupType(AppCenterBehaviorAdvanced advancedSettings)
|
||||
{
|
||||
return advancedSettings != null && advancedSettings.SettingsAdvanced != null ?
|
||||
advancedSettings.SettingsAdvanced.GetStartupType() :
|
||||
StartupType.AppCenter;
|
||||
}
|
||||
|
||||
private string GetTransmissionTargetToken(AppCenterBehaviorAdvanced advancedSettings)
|
||||
{
|
||||
return advancedSettings != null && advancedSettings.SettingsAdvanced != null ?
|
||||
advancedSettings.SettingsAdvanced.TransmissionTargetToken :
|
||||
string.Empty;
|
||||
}
|
||||
|
||||
private string GetAppSecretString(string appSecret, string transmissionTargetToken, StartupType startupType)
|
||||
{
|
||||
#if UNITY_WSA_10_0
|
||||
return appSecret;
|
||||
#else
|
||||
switch (startupType)
|
||||
{
|
||||
default:
|
||||
case StartupType.AppCenter:
|
||||
return appSecret;
|
||||
case StartupType.NoSecret:
|
||||
return string.Empty;
|
||||
case StartupType.OneCollector:
|
||||
return string.Format("target={0}", transmissionTargetToken);
|
||||
case StartupType.Both:
|
||||
return string.Format("appsecret={0};target={1}", appSecret, transmissionTargetToken);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void PrepareEventHandlers(Type[] services)
|
||||
{
|
||||
foreach (var service in services)
|
||||
{
|
||||
var method = service.GetMethod("PrepareEventHandlers");
|
||||
if (method != null)
|
||||
{
|
||||
method.Invoke(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void InvokeInitializingServices()
|
||||
{
|
||||
if (InitializingServices != null)
|
||||
{
|
||||
InitializingServices.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private static void InvokeInitializedServices()
|
||||
{
|
||||
if (InitializedAppCenterAndServices != null)
|
||||
{
|
||||
InitializedAppCenterAndServices.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/AppCenterBehavior.cs.meta
Normal file
12
Assets/AppCenter/AppCenterBehavior.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9a3a6a28c6a80a46adde9b4e01eeb93
|
||||
timeCreated: 1502267991
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 2778c316eec875d46bbd2ecbfba6db4a, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/AppCenter/AppCenterBehaviorAdvanced.cs
Normal file
30
Assets/AppCenter/AppCenterBehaviorAdvanced.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[HelpURL("https://docs.microsoft.com/en-us/appcenter/sdk/crashes/unity")]
|
||||
public class AppCenterBehaviorAdvanced : MonoBehaviour
|
||||
{
|
||||
public AppCenterSettingsAdvanced SettingsAdvanced;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Make sure that App Center have the default behavior attached.
|
||||
if (gameObject.GetComponent<AppCenterBehavior>() == null)
|
||||
{
|
||||
Debug.LogError("App Center Behavior Advanced should have the App Center Behavior instance attached to the same game object.");
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void Reset()
|
||||
{
|
||||
if (FindObjectsOfType<AppCenterBehaviorAdvanced>().Length > 1)
|
||||
{
|
||||
Debug.LogError("Only one game object with App Center Behaviour Advanced should exist.");
|
||||
DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
11
Assets/AppCenter/AppCenterBehaviorAdvanced.cs.meta
Normal file
11
Assets/AppCenter/AppCenterBehaviorAdvanced.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d5e2b5dc171f164b8ef2a7b94198b04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 2778c316eec875d46bbd2ecbfba6db4a, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/AppCenter/AppCenterSettings.asset
Normal file
40
Assets/AppCenter/AppCenterSettings.asset
Normal file
@ -0,0 +1,40 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 07ef30b23b2586041aedf18c9486176d, type: 3}
|
||||
m_Name: AppCenterSettings
|
||||
m_EditorClassIdentifier:
|
||||
iOSAppSecret: d8e69880-4b16-468e-9216-d0eec8fff482
|
||||
AndroidAppSecret: d212c44e-8438-499e-83b8-dbb0b6cafc54
|
||||
UWPAppSecret: 43bc58e0-d103-4d4a-87e6-ddc26adff8ba
|
||||
UseAnalytics: 1
|
||||
UseCrashes: 1
|
||||
UseDistribute: 1
|
||||
CustomApiUrl:
|
||||
UrlName: API
|
||||
UseCustomUrl: 0
|
||||
Url:
|
||||
CustomInstallUrl:
|
||||
UrlName: Install
|
||||
UseCustomUrl: 0
|
||||
Url:
|
||||
EnableDistributeForDebuggableBuild: 0
|
||||
AutomaticCheckForUpdate: 1
|
||||
InitialLogLevel: 4
|
||||
AllowNetworkRequests: 1
|
||||
UpdateTrack: 1
|
||||
CustomLogUrl:
|
||||
UrlName: Log
|
||||
UseCustomUrl: 0
|
||||
Url:
|
||||
MaxStorageSize:
|
||||
UseCustomMaxStorageSize: 0
|
||||
Size: 0
|
||||
8
Assets/AppCenter/AppCenterSettings.asset.meta
Normal file
8
Assets/AppCenter/AppCenterSettings.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4dbc5962d52f8a4886748301216ab73
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
92
Assets/AppCenter/AppCenterSettings.cs
Normal file
92
Assets/AppCenter/AppCenterSettings.cs
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AppCenter.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class AppCenterSettings : ScriptableObject
|
||||
{
|
||||
[AppSecret("iOS App Secret")]
|
||||
public string iOSAppSecret = "";
|
||||
|
||||
[AppSecret]
|
||||
public string AndroidAppSecret = "";
|
||||
|
||||
[AppSecret]
|
||||
public string UWPAppSecret = "";
|
||||
|
||||
[Tooltip("App Center Analytics helps you understand user behavior and customer engagement to improve your app.")]
|
||||
public bool UseAnalytics = true;
|
||||
|
||||
[Tooltip("App Center Crashes will automatically generate a crash log every time your app crashes.")]
|
||||
public bool UseCrashes = true;
|
||||
|
||||
[Tooltip("App Center Distribute will let your users install a new version of the app when you distribute it via the App Center.")]
|
||||
public bool UseDistribute = true;
|
||||
|
||||
public CustomUrlProperty CustomApiUrl = new CustomUrlProperty("API");
|
||||
|
||||
public CustomUrlProperty CustomInstallUrl = new CustomUrlProperty("Install");
|
||||
|
||||
[Tooltip("By default, App Center Distribute is disabled for debuggable builds. Check this to enable it.")]
|
||||
public bool EnableDistributeForDebuggableBuild = false;
|
||||
|
||||
[Tooltip("By default, App Center Distribute checks for update at application startup automatically. Uncheck this to check for updates manually instead.")]
|
||||
public bool AutomaticCheckForUpdate = true;
|
||||
|
||||
public LogLevel InitialLogLevel = LogLevel.Info;
|
||||
|
||||
[Tooltip("By default, the network requests is allowed. Uncheck this to disallow network requests.")]
|
||||
public bool AllowNetworkRequests = true;
|
||||
|
||||
[CustomDropDownProperty("Public", 1)]
|
||||
[CustomDropDownProperty("Private", 2)]
|
||||
public int UpdateTrack;
|
||||
|
||||
public CustomUrlProperty CustomLogUrl = new CustomUrlProperty("Log");
|
||||
|
||||
public MaxStorageSizeProperty MaxStorageSize = new MaxStorageSizeProperty();
|
||||
|
||||
public string AppSecret
|
||||
{
|
||||
get
|
||||
{
|
||||
var appSecrets = new Dictionary<string, string>
|
||||
{
|
||||
{ "ios", iOSAppSecret },
|
||||
{ "android", AndroidAppSecret },
|
||||
{ "uwp", UWPAppSecret }
|
||||
};
|
||||
return string.Concat(appSecrets
|
||||
.Where(i => !string.IsNullOrEmpty(i.Value))
|
||||
.Select(i => string.Format("{0}={1};", i.Key, i.Value))
|
||||
.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public Type[] Services
|
||||
{
|
||||
get
|
||||
{
|
||||
var services = new List<Type>();
|
||||
if (UseAnalytics)
|
||||
{
|
||||
services.Add(AppCenter.Analytics);
|
||||
}
|
||||
if (UseCrashes)
|
||||
{
|
||||
services.Add(AppCenter.Crashes);
|
||||
}
|
||||
if (UseDistribute)
|
||||
{
|
||||
services.Add(AppCenter.Distribute);
|
||||
}
|
||||
return services.Where(i => i != null).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/AppCenterSettings.cs.meta
Normal file
12
Assets/AppCenter/AppCenterSettings.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07ef30b23b2586041aedf18c9486176d
|
||||
timeCreated: 1502272754
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/AppCenter/AppCenterSettingsAdvanced.cs
Normal file
50
Assets/AppCenter/AppCenterSettingsAdvanced.cs
Normal file
@ -0,0 +1,50 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.AppCenter.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class AppCenterSettingsAdvanced : ScriptableObject
|
||||
{
|
||||
[AppSecret("Transmission Target Token")]
|
||||
public string TransmissionTargetToken = "";
|
||||
|
||||
[Tooltip("Configure the way App Center is started. For more info on startup types refer to the documentation.")]
|
||||
public StartupType AppCenterStartupType = StartupType.Both;
|
||||
|
||||
[Tooltip("Start Android native SDK from the App Center Behavior script instead of the native plugin")]
|
||||
#if APPCENTER_DONT_USE_NATIVE_STARTER
|
||||
public bool StartAndroidNativeSDKFromAppCenterBehavior = true;
|
||||
#else
|
||||
public bool StartAndroidNativeSDKFromAppCenterBehavior = false;
|
||||
#endif
|
||||
|
||||
[Tooltip("Start iOS native SDK from the App Center Behavior script instead of the native plugin")]
|
||||
#if APPCENTER_DONT_USE_NATIVE_STARTER
|
||||
public bool StartIOSNativeSDKFromAppCenterBehavior = true;
|
||||
#else
|
||||
public bool StartIOSNativeSDKFromAppCenterBehavior = false;
|
||||
#endif
|
||||
|
||||
public StartupType GetStartupType()
|
||||
{
|
||||
return AppCenterStartupType == StartupType.Both && string.IsNullOrEmpty(TransmissionTargetToken) ?
|
||||
StartupType.AppCenter :
|
||||
AppCenterStartupType;
|
||||
}
|
||||
|
||||
private static Assembly AppCenterAssembly
|
||||
{
|
||||
get
|
||||
{
|
||||
#if !UNITY_EDITOR && UNITY_WSA_10_0
|
||||
return typeof(AppCenterSettingsAdvanced).GetTypeInfo().Assembly;
|
||||
#else
|
||||
return Assembly.GetExecutingAssembly();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/AppCenter/AppCenterSettingsAdvanced.cs.meta
Normal file
11
Assets/AppCenter/AppCenterSettingsAdvanced.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0254b6f16506aa345aa7e5b4229b8fdc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/AppCenter/Editor.meta
Normal file
9
Assets/AppCenter/Editor.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d57433ef86b55d4f891a2bae99af818
|
||||
folderAsset: yes
|
||||
timeCreated: 1502266378
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
108
Assets/AppCenter/Editor/AndroidLibraryHelper.cs
Normal file
108
Assets/AppCenter/Editor/AndroidLibraryHelper.cs
Normal file
@ -0,0 +1,108 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public static class AndroidLibraryHelper
|
||||
{
|
||||
public static void ZipFile(string sourceFile, string destinationFile)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
var args = "";
|
||||
var processName = "";
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
args = stringBuilder
|
||||
.Append("/c powershell")
|
||||
.Append(" -executionpolicy bypass")
|
||||
.Append(" -File \"")
|
||||
.Append(AppCenterSettingsContext.AppCenterPath)
|
||||
.Append("/Plugins/Android/Utility/archive.ps1 \"")
|
||||
.Append(" -Source ")
|
||||
.Append(sourceFile)
|
||||
.Append(" -Destination ")
|
||||
.Append(destinationFile)
|
||||
.ToString();
|
||||
processName = "cmd";
|
||||
}
|
||||
else if (Application.platform == RuntimePlatform.OSXEditor)
|
||||
{
|
||||
args = stringBuilder
|
||||
.Append("-c \"cd ")
|
||||
.Append(sourceFile)
|
||||
.Append(" ; zip -r ")
|
||||
.Append("../")
|
||||
.Append(destinationFile)
|
||||
.Append(" * \"")
|
||||
.ToString();
|
||||
processName = "/bin/bash";
|
||||
}
|
||||
if (processName.Length > 0)
|
||||
{
|
||||
ExecuteProcess(processName, args);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnzipFile(string sourceFile, string destinationFile)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
var args = "";
|
||||
var processName = "";
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
args = stringBuilder
|
||||
.Append("/c powershell")
|
||||
.Append(" -executionpolicy bypass")
|
||||
.Append(" -File \"")
|
||||
.Append(AppCenterSettingsContext.AppCenterPath)
|
||||
.Append("/Plugins/Android/Utility/unarchive.ps1 \"")
|
||||
.Append(" -Source ")
|
||||
.Append(sourceFile)
|
||||
.Append(" -Destination ")
|
||||
.Append(destinationFile)
|
||||
.ToString();
|
||||
processName = "cmd";
|
||||
}
|
||||
else if (Application.platform == RuntimePlatform.OSXEditor)
|
||||
{
|
||||
args = stringBuilder
|
||||
.Append("-c \"unzip ")
|
||||
.Append(sourceFile)
|
||||
.Append(" -d ")
|
||||
.Append(destinationFile)
|
||||
.Append(" \"")
|
||||
.ToString();
|
||||
processName = "/bin/bash";
|
||||
}
|
||||
if (processName.Length > 0)
|
||||
{
|
||||
ExecuteProcess(processName, args);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ExecuteProcess(string processName, string args)
|
||||
{
|
||||
var process = new Process()
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = processName,
|
||||
Arguments = args,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
}
|
||||
};
|
||||
process.Start();
|
||||
string output = process.StandardOutput.ReadToEnd();
|
||||
string error = process.StandardError.ReadToEnd();
|
||||
process.WaitForExit();
|
||||
if (output.Length > 0 || error.Length > 0)
|
||||
{
|
||||
UnityEngine.Debug.Log(output + error);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/AppCenter/Editor/AndroidLibraryHelper.cs.meta
Normal file
11
Assets/AppCenter/Editor/AndroidLibraryHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dd8894ba1c74f64eba3405e0e466702
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/AppCenter/Editor/AppCenterBehaviorEditor.cs
Normal file
30
Assets/AppCenter/Editor/AppCenterBehaviorEditor.cs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
[CustomEditor(typeof(AppCenterBehavior))]
|
||||
public class AppCenterBehaviorEditor : Editor
|
||||
{
|
||||
private Editor settingsEditor;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
// Load or create settings.
|
||||
var behaviour = (AppCenterBehavior) target;
|
||||
if (behaviour.Settings == null)
|
||||
{
|
||||
behaviour.Settings = AppCenterSettingsContext.SettingsInstance;
|
||||
EditorUtility.SetDirty(behaviour);
|
||||
EditorSceneManager.MarkSceneDirty(behaviour.gameObject.scene);
|
||||
}
|
||||
|
||||
// Draw settings.
|
||||
if (settingsEditor == null)
|
||||
{
|
||||
settingsEditor = CreateEditor(behaviour.Settings);
|
||||
}
|
||||
settingsEditor.OnInspectorGUI();
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/Editor/AppCenterBehaviorEditor.cs.meta
Normal file
12
Assets/AppCenter/Editor/AppCenterBehaviorEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b75da1d7e1a6444bb6ca0bfefc96bca
|
||||
timeCreated: 1502266489
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/AppCenter/Editor/AppCenterBehaviorEditorAdvanced.cs
Normal file
36
Assets/AppCenter/Editor/AppCenterBehaviorEditorAdvanced.cs
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
[CustomEditor(typeof(AppCenterBehaviorAdvanced))]
|
||||
public class AppCenterBehaviorEditorAdvanced : Editor
|
||||
{
|
||||
private Editor settingsEditorAdvanced;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
// Load or create settings.
|
||||
var behaviour = (AppCenterBehaviorAdvanced) target;
|
||||
if (behaviour.SettingsAdvanced == null)
|
||||
{
|
||||
behaviour.SettingsAdvanced = AppCenterSettingsContext.CreateSettingsInstanceAdvanced();
|
||||
}
|
||||
|
||||
// Draw settings.
|
||||
if (settingsEditorAdvanced == null)
|
||||
{
|
||||
settingsEditorAdvanced = CreateEditor(behaviour.SettingsAdvanced);
|
||||
}
|
||||
settingsEditorAdvanced.OnInspectorGUI();
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
// If the component is removed from GameObject then remove the related asset.
|
||||
if (!target && FindObjectsOfType<AppCenterBehaviorAdvanced>().Length == 0)
|
||||
{
|
||||
AppCenterSettingsContext.DeleteSettingsInstanceAdvanced();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a931e43ece37e0f49a55725bf9250637
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/AppCenter/Editor/AppCenterIcon.png
Normal file
BIN
Assets/AppCenter/Editor/AppCenterIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 924 B |
106
Assets/AppCenter/Editor/AppCenterIcon.png.meta
Normal file
106
Assets/AppCenter/Editor/AppCenterIcon.png.meta
Normal file
@ -0,0 +1,106 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2778c316eec875d46bbd2ecbfba6db4a
|
||||
timeCreated: 1502267776
|
||||
licenseType: Free
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 0
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: 1
|
||||
mipBias: -1
|
||||
wrapU: 1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 2
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: iPhone
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: Windows Store Apps
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
340
Assets/AppCenter/Editor/AppCenterPostBuild.cs
Normal file
340
Assets/AppCenter/Editor/AppCenterPostBuild.cs
Normal file
@ -0,0 +1,340 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.AppCenter.Unity;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.Reflection;
|
||||
|
||||
// Warning: Don't use #if #endif for conditional compilation here as Unity
|
||||
// doesn't always set the flags early enough.
|
||||
|
||||
public class AppCenterPostBuild : IPostprocessBuildWithReport
|
||||
{
|
||||
public int callbackOrder { get { return 0; } }
|
||||
|
||||
private const string AppManifestFileName = "Package.appxmanifest";
|
||||
private const string CapabilitiesElement = "Capabilities";
|
||||
private const string CapabilityElement = "Capability";
|
||||
private const string CapabilityNameAttribute = "Name";
|
||||
private const string CapabilityNameAttributeValue = "internetClient";
|
||||
private const string AppIl2cppXaml = "App.xaml.cpp";
|
||||
private const string AppIl2cppD3d = "App.cpp";
|
||||
|
||||
public void OnPostprocessBuild(BuildReport report)
|
||||
{
|
||||
OnPostprocessBuild(report.summary.platform, report.summary.outputPath);
|
||||
}
|
||||
|
||||
public void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
|
||||
{
|
||||
if (target == BuildTarget.WSAPlayer)
|
||||
{
|
||||
AddInternetClientCapability(pathToBuiltProject);
|
||||
if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA) == ScriptingImplementation.IL2CPP)
|
||||
{
|
||||
// Fix System.Diagnostics.Debug IL2CPP implementation.
|
||||
FixIl2CppLogging(pathToBuiltProject);
|
||||
}
|
||||
}
|
||||
if (target == BuildTarget.iOS &&
|
||||
PBXProjectWrapper.PBXProjectIsAvailable &&
|
||||
PlistDocumentWrapper.PlistDocumentIsAvailable)
|
||||
{
|
||||
var pbxProject = new PBXProjectWrapper(pathToBuiltProject);
|
||||
|
||||
// Update project.
|
||||
OnPostprocessProject(pbxProject);
|
||||
pbxProject.WriteToFile();
|
||||
|
||||
// Update Info.plist.
|
||||
var settings = AppCenterSettingsContext.SettingsInstance;
|
||||
var infoPath = pathToBuiltProject + "/Info.plist";
|
||||
var info = new PlistDocumentWrapper(infoPath);
|
||||
OnPostprocessInfo(info, settings);
|
||||
info.WriteToFile();
|
||||
|
||||
// Update capabilities (if possible).
|
||||
if (ProjectCapabilityManagerWrapper.ProjectCapabilityManagerIsAvailable)
|
||||
{
|
||||
var capabilityManager = new ProjectCapabilityManagerWrapper(pbxProject.ProjectPath,
|
||||
PBXProjectWrapper.GetUnityTargetName(),
|
||||
pbxProject.GetUnityTargetGuid());
|
||||
capabilityManager.WriteToFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region UWP Methods
|
||||
|
||||
/// <summary>
|
||||
/// In order to have App Center SDK logs we are using 'OutputDebugStringW' func to display them.
|
||||
/// To use 'OutputDebugStringW' we should update autogenerated Debugger.cpp file.
|
||||
/// </summary>
|
||||
/// <param name="pathToBuiltProject">Path to build project</param>
|
||||
public static void FixIl2CppLogging(string pathToBuiltProject)
|
||||
{
|
||||
var destDebuggerPath = Path.Combine(pathToBuiltProject,
|
||||
"Il2CppOutputProject\\IL2CPP\\libil2cpp\\icalls\\mscorlib\\System.Diagnostics\\Debugger.cpp");
|
||||
if (!File.Exists(destDebuggerPath))
|
||||
{
|
||||
throw new FileNotFoundException("Debugger.cpp file not found");
|
||||
}
|
||||
var codeLines = File.ReadAllLines(destDebuggerPath).ToList();
|
||||
|
||||
// Update #include and #undef derictives.
|
||||
var lastIncludeLineIndex = SearchForLine(codeLines, "#include", true);
|
||||
if (lastIncludeLineIndex == -1)
|
||||
{
|
||||
throw new Exception("Unexpected content of Debugger.cpp");
|
||||
}
|
||||
|
||||
// Add '#include <Windows.h>' which provides 'OutputDebugStringW'.
|
||||
codeLines.Insert(lastIncludeLineIndex + 1, "#include <Windows.h>");
|
||||
|
||||
/*
|
||||
* 'GetCurrentDirectory' define conflicts with generated code and new versions of Unity
|
||||
* combine some files on the compilation so the changes in one file can affect another.
|
||||
*/
|
||||
codeLines.Insert(lastIncludeLineIndex + 2, "#undef GetCurrentDirectory");
|
||||
|
||||
// Add logging method.
|
||||
var logMethodLineIndex = SearchForLine(codeLines, "void Debugger::Log");
|
||||
if (logMethodLineIndex == -1)
|
||||
{
|
||||
throw new Exception("Unexpected content of Debugger.cpp");
|
||||
}
|
||||
var insertingPosition = GetFirstLineInMethodBody(codeLines, logMethodLineIndex);
|
||||
codeLines.Insert(insertingPosition, "OutputDebugStringW(message->chars);");
|
||||
|
||||
// Enable logging.
|
||||
var isLoggingMethodLineIndex = SearchForLine(codeLines, "bool Debugger::IsLogging");
|
||||
if (isLoggingMethodLineIndex == -1)
|
||||
{
|
||||
throw new Exception("Unexpected content of Debugger.cpp");
|
||||
}
|
||||
var firstLineInMethodBody = GetFirstLineInMethodBody(codeLines, isLoggingMethodLineIndex);
|
||||
var lastLineInMethodBody = GetLastLineInMethodBody(codeLines, isLoggingMethodLineIndex);
|
||||
codeLines.RemoveRange(firstLineInMethodBody, lastLineInMethodBody - firstLineInMethodBody);
|
||||
codeLines.Insert(firstLineInMethodBody, "return true;");
|
||||
File.WriteAllLines(destDebuggerPath, codeLines.ToArray());
|
||||
}
|
||||
|
||||
private static int GetFirstLineInMethodBody(List<string> lines, int currentLineIndex)
|
||||
{
|
||||
while (currentLineIndex <= lines.Count && !lines[currentLineIndex].Contains("{"))
|
||||
{
|
||||
currentLineIndex++;
|
||||
}
|
||||
if (currentLineIndex >= lines.Count)
|
||||
{
|
||||
throw new Exception("Unexpected content of Debugger.cpp");
|
||||
}
|
||||
return currentLineIndex + 1;
|
||||
}
|
||||
|
||||
private static int GetLastLineInMethodBody(List<string> lines, int currentLineIndex)
|
||||
{
|
||||
var lineIndex = GetFirstLineInMethodBody(lines, currentLineIndex);
|
||||
int bracketsBalance = lines[lineIndex - 1].Count((item) => item == '{');
|
||||
while (lineIndex <= lines.Count && bracketsBalance != 0)
|
||||
{
|
||||
bracketsBalance += lines[lineIndex].Count((item) => item == '{');
|
||||
bracketsBalance -= lines[lineIndex].Count((item) => item == '}');
|
||||
lineIndex++;
|
||||
}
|
||||
if (bracketsBalance != 0)
|
||||
{
|
||||
throw new Exception("Unexpected content of Debugger.cpp");
|
||||
}
|
||||
return lineIndex - 1;
|
||||
}
|
||||
|
||||
private static int SearchForLine(List<string> lines, string searchString, bool returnTheLast = false)
|
||||
{
|
||||
int position = -1;
|
||||
for (var i = 0; i < lines.Count; i++)
|
||||
{
|
||||
if (lines[i].Contains(searchString))
|
||||
{
|
||||
if (returnTheLast)
|
||||
{
|
||||
position = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
public static string GetAppFilePath(string pathToBuiltProject, string filename)
|
||||
{
|
||||
var candidate = Path.Combine(pathToBuiltProject, Application.productName);
|
||||
candidate = Path.Combine(candidate, filename);
|
||||
return File.Exists(candidate) ? candidate : null;
|
||||
}
|
||||
|
||||
public static void ProcessUwpIl2CppDependencies()
|
||||
{
|
||||
var binaries = AssetDatabase.FindAssets("*", new[] { AppCenterSettingsContext.AppCenterPath + "/Plugins/WSA/IL2CPP" });
|
||||
foreach (var guid in binaries)
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var importer = AssetImporter.GetAtPath(assetPath) as PluginImporter;
|
||||
if (importer != null)
|
||||
{
|
||||
importer.SetPlatformData(BuildTarget.WSAPlayer, "SDK", "UWP");
|
||||
importer.SetPlatformData(BuildTarget.WSAPlayer, "ScriptingBackend", "Il2Cpp");
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ExecuteCommand(string command, string arguments, int timeout = 600)
|
||||
{
|
||||
try
|
||||
{
|
||||
var buildProcess = new System.Diagnostics.Process
|
||||
{
|
||||
StartInfo =
|
||||
{
|
||||
FileName = command,
|
||||
Arguments = arguments
|
||||
}
|
||||
};
|
||||
buildProcess.Start();
|
||||
buildProcess.WaitForExit(timeout * 1000);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddInternetClientCapability(string pathToBuiltProject)
|
||||
{
|
||||
/* Package.appxmanifest file example:
|
||||
<Package>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package> */
|
||||
|
||||
var appManifests = Directory.GetFiles(pathToBuiltProject, AppManifestFileName, SearchOption.AllDirectories);
|
||||
if (appManifests.Length == 0)
|
||||
{
|
||||
Debug.LogWarning("Failed to add the `InternetClient` capability, file `" + AppManifestFileName + "` is not found");
|
||||
return;
|
||||
}
|
||||
else if (appManifests.Length > 1)
|
||||
{
|
||||
Debug.LogWarning("Failed to add the `InternetClient` capability, multiple `" + AppManifestFileName + "` files found");
|
||||
return;
|
||||
}
|
||||
|
||||
var appManifestFilePath = appManifests[0];
|
||||
var xmlFile = XDocument.Load(appManifestFilePath);
|
||||
var defaultNamespace = xmlFile.Root.GetDefaultNamespace().NamespaceName;
|
||||
var capabilitiesElements = xmlFile.Root.Elements().Where(element => element.Name.LocalName == CapabilitiesElement).ToList();
|
||||
if (capabilitiesElements.Count > 1)
|
||||
{
|
||||
Debug.LogWarning("Failed to add the `InternetClient` capability, multiple `Capabilities` elements found inside `" + appManifestFilePath + "` file");
|
||||
return;
|
||||
}
|
||||
else if (capabilitiesElements.Count == 0)
|
||||
{
|
||||
xmlFile.Root.Add(new XElement(XName.Get(CapabilitiesElement, defaultNamespace), GetInternetClientCapabilityElement(defaultNamespace)));
|
||||
}
|
||||
else // capabilitiesElements.Count == 1
|
||||
{
|
||||
var capabilitiesElement = capabilitiesElements[0];
|
||||
foreach (var element in capabilitiesElement.Elements())
|
||||
{
|
||||
if (element.Name.LocalName == CapabilityElement &&
|
||||
GetAttributeValue(element, CapabilityNameAttribute) == CapabilityNameAttributeValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
capabilitiesElement.Add(GetInternetClientCapabilityElement(defaultNamespace));
|
||||
}
|
||||
xmlFile.Save(appManifestFilePath);
|
||||
}
|
||||
|
||||
private static XElement GetInternetClientCapabilityElement(string defaultNamespace)
|
||||
{
|
||||
return new XElement(XName.Get(CapabilityElement, defaultNamespace),
|
||||
new XAttribute(CapabilityNameAttribute, CapabilityNameAttributeValue));
|
||||
}
|
||||
|
||||
internal static string GetAttributeValue(XElement element, string attributeName)
|
||||
{
|
||||
var attribute = element.Attribute(attributeName);
|
||||
return attribute == null ? null : attribute.Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region iOS Methods
|
||||
private static void OnPostprocessProject(PBXProjectWrapper project)
|
||||
{
|
||||
// Need to add SQLite and zlib dependencies.
|
||||
project.AddBuildProperty("OTHER_LDFLAGS", "-lsqlite3 -lz");
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
project.AddBuildProperty("CLANG_ENABLE_MODULES", "YES", true);
|
||||
#else
|
||||
project.AddBuildProperty("CLANG_ENABLE_MODULES", "YES");
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void OnPostprocessInfo(PlistDocumentWrapper info, AppCenterSettings settings)
|
||||
{
|
||||
if (settings.UseDistribute && AppCenter.Distribute != null)
|
||||
{
|
||||
// Add App Center URL scemes.
|
||||
var schemes = new List<string>() { "appcenter-" + settings.iOSAppSecret };
|
||||
|
||||
// Create a reflection call for getting custom schemes from iOS settings.
|
||||
var playerSettingsClass = typeof(PlayerSettings.iOS);
|
||||
var iOSURLSchemesMethod = playerSettingsClass.GetMethod("GetURLSchemes", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
|
||||
// Verify that method exists and call it for getting custom schemes.
|
||||
if (iOSURLSchemesMethod != null)
|
||||
{
|
||||
var schemesFromSettings = (string[])iOSURLSchemesMethod.Invoke(null, null);
|
||||
schemes.AddRange(schemesFromSettings.ToList<string>());
|
||||
}
|
||||
|
||||
// Generate scheme information.
|
||||
var root = info.GetRoot();
|
||||
var urlTypes = root.GetType().GetMethod("CreateArray").Invoke(root, new object[] { "CFBundleURLTypes" });
|
||||
if (settings.UseDistribute && AppCenter.Distribute != null)
|
||||
{
|
||||
var urlType = urlTypes.GetType().GetMethod("AddDict").Invoke(urlTypes, null);
|
||||
var setStringMethod = urlType.GetType().GetMethod("SetString");
|
||||
setStringMethod.Invoke(urlType, new object[] { "CFBundleTypeRole", "None" });
|
||||
setStringMethod.Invoke(urlType, new object[] { "CFBundleURLName", ApplicationIdHelper.GetApplicationId() });
|
||||
var urlSchemes = urlType.GetType().GetMethod("CreateArray").Invoke(urlType, new[] { "CFBundleURLSchemes" });
|
||||
|
||||
// Add custom schemes defined in Unity players settings.
|
||||
foreach (var scheme in schemes)
|
||||
{
|
||||
urlSchemes.GetType().GetMethod("AddString").Invoke(urlSchemes, new[] { scheme });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
12
Assets/AppCenter/Editor/AppCenterPostBuild.cs.meta
Normal file
12
Assets/AppCenter/Editor/AppCenterPostBuild.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c0067cc6476946b180484e48966b142
|
||||
timeCreated: 1497896393
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
190
Assets/AppCenter/Editor/AppCenterPreBuild.cs
Normal file
190
Assets/AppCenter/Editor/AppCenterPreBuild.cs
Normal file
@ -0,0 +1,190 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.AppCenter.Unity;
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
public class AppCenterPreBuild : IPreprocessBuildWithReport
|
||||
{
|
||||
private const string AarFilePattern = "appcenter-{0}-release";
|
||||
public int callbackOrder { get { return 0; } }
|
||||
#if UNITY_WSA
|
||||
private readonly Version RequiredMinimalUWPVersion = new Version("10.0.16299.0");
|
||||
#endif
|
||||
|
||||
public void OnPreprocessBuild(BuildReport report)
|
||||
{
|
||||
OnPreprocessBuild(report.summary.platform, report.summary.outputPath);
|
||||
}
|
||||
|
||||
public void OnPreprocessBuild(BuildTarget target, string path)
|
||||
{
|
||||
if (target == BuildTarget.Android)
|
||||
{
|
||||
#if !APPCENTER_DONT_USE_NATIVE_STARTER
|
||||
var settingsMaker = new AppCenterSettingsMakerAndroid();
|
||||
AddStartupCode(settingsMaker);
|
||||
#if UNITY_ANDROID
|
||||
AddSettingsFileToLoader(settingsMaker);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if (target == BuildTarget.iOS)
|
||||
{
|
||||
#if !APPCENTER_DONT_USE_NATIVE_STARTER
|
||||
AddStartupCode(new AppCenterSettingsMakerIos());
|
||||
#endif
|
||||
}
|
||||
else if (target == BuildTarget.WSAPlayer)
|
||||
{
|
||||
#if UNITY_WSA
|
||||
var currentMinimalPlatformVersion = new Version(EditorUserBuildSettings.wsaMinUWPSDK);
|
||||
if (currentMinimalPlatformVersion < RequiredMinimalUWPVersion)
|
||||
{
|
||||
Debug.LogWarning($"Minimum platform version should be set to {RequiredMinimalUWPVersion} or higher. App Center does not support lower versions but it is set to {currentMinimalPlatformVersion}");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (target == BuildTarget.Android)
|
||||
{
|
||||
// No linking/unlinking in case module isn't added.
|
||||
if (AppCenter.Distribute != null)
|
||||
{
|
||||
LinkModule(AppCenterSettingsContext.SettingsInstance.UseDistribute, "distribute");
|
||||
}
|
||||
if (AppCenter.Analytics != null)
|
||||
{
|
||||
LinkModule(AppCenterSettingsContext.SettingsInstance.UseAnalytics, "analytics");
|
||||
}
|
||||
if (AppCenter.Crashes != null)
|
||||
{
|
||||
LinkModule(AppCenterSettingsContext.SettingsInstance.UseCrashes, "crashes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_ANDROID
|
||||
public static void AddSettingsFileToLoader(AppCenterSettingsMakerAndroid settingsMaker)
|
||||
{
|
||||
var loaderZipFile = AppCenterSettingsContext.AppCenterPath + "/Plugins/Android/appcenter-loader-release.aar";
|
||||
const string loaderFolder = "appcenter-loader-release";
|
||||
const string settingsFilePath = loaderFolder + "/res/values/appcenter-settings.xml";
|
||||
const string settingsMetaFilePath = loaderFolder + "/res/values/appcenter-settings.xml.meta";
|
||||
|
||||
if (!File.Exists(loaderZipFile))
|
||||
{
|
||||
throw new IOException("Failed to load dependency file appcenter-loader-release.aar");
|
||||
}
|
||||
|
||||
// Delete unzipped directory if it already exists.
|
||||
if (Directory.Exists(loaderFolder))
|
||||
{
|
||||
Directory.Delete(loaderFolder, true);
|
||||
}
|
||||
|
||||
AndroidLibraryHelper.UnzipFile(loaderZipFile, loaderFolder);
|
||||
if (!Directory.Exists(loaderFolder))
|
||||
{
|
||||
throw new IOException("Unzipping loader folder failed.");
|
||||
}
|
||||
|
||||
settingsMaker.CommitSettings(settingsFilePath);
|
||||
|
||||
// Delete the appcenter-settings.xml.meta file if generated.
|
||||
if (File.Exists(settingsMetaFilePath))
|
||||
{
|
||||
File.Delete(settingsMetaFilePath);
|
||||
}
|
||||
|
||||
// Delete the original aar file and zipped the extracted folder to generate a new one.
|
||||
File.Delete(loaderZipFile);
|
||||
AndroidLibraryHelper.ZipFile(loaderFolder, loaderZipFile);
|
||||
Directory.Delete(loaderFolder, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
private void AddStartupCode(IAppCenterSettingsMaker settingsMaker)
|
||||
{
|
||||
var settings = AppCenterSettingsContext.SettingsInstance;
|
||||
var advancedSettings = AppCenterSettingsContext.SettingsInstanceAdvanced;
|
||||
settingsMaker.SetAppSecret(settings);
|
||||
settingsMaker.SetLogLevel((int)settings.InitialLogLevel);
|
||||
settingsMaker.IsAllowNetworkRequests((bool)settings.AllowNetworkRequests);
|
||||
if (settings.CustomLogUrl.UseCustomUrl)
|
||||
{
|
||||
settingsMaker.SetLogUrl(settings.CustomLogUrl.Url);
|
||||
}
|
||||
if (settings.MaxStorageSize.UseCustomMaxStorageSize && settings.MaxStorageSize.Size > 0)
|
||||
{
|
||||
settingsMaker.SetMaxStorageSize(settings.MaxStorageSize.Size);
|
||||
}
|
||||
if (settings.UseAnalytics && settingsMaker.IsAnalyticsAvailable())
|
||||
{
|
||||
settingsMaker.StartAnalyticsClass();
|
||||
}
|
||||
if (settings.UseCrashes && settingsMaker.IsCrashesAvailable())
|
||||
{
|
||||
settingsMaker.StartCrashesClass();
|
||||
}
|
||||
if (settings.UseDistribute && settingsMaker.IsDistributeAvailable())
|
||||
{
|
||||
if (settings.CustomApiUrl.UseCustomUrl)
|
||||
{
|
||||
settingsMaker.SetApiUrl(settings.CustomApiUrl.Url);
|
||||
}
|
||||
if (settings.CustomInstallUrl.UseCustomUrl)
|
||||
{
|
||||
settingsMaker.SetInstallUrl(settings.CustomInstallUrl.Url);
|
||||
}
|
||||
if (settings.EnableDistributeForDebuggableBuild)
|
||||
{
|
||||
settingsMaker.SetShouldEnableDistributeForDebuggableBuild();
|
||||
}
|
||||
if (!settings.AutomaticCheckForUpdate)
|
||||
{
|
||||
settingsMaker.SetDistributeDisableAutomaticCheckForUpdate();
|
||||
}
|
||||
settingsMaker.SetUpdateTrack(settings.UpdateTrack);
|
||||
settingsMaker.StartDistributeClass();
|
||||
}
|
||||
if (advancedSettings != null)
|
||||
{
|
||||
var startupType = settingsMaker.IsStartFromAppCenterBehavior(advancedSettings) ? StartupType.Skip : advancedSettings.GetStartupType();
|
||||
settingsMaker.SetStartupType((int)startupType);
|
||||
settingsMaker.SetTransmissionTargetToken(advancedSettings.TransmissionTargetToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsMaker.SetStartupType((int)StartupType.AppCenter);
|
||||
}
|
||||
settingsMaker.CommitSettings();
|
||||
}
|
||||
|
||||
#region Android Methods
|
||||
|
||||
private static void LinkModule(bool isEnabled, string moduleName)
|
||||
{
|
||||
var aarName = string.Format(AarFilePattern, moduleName);
|
||||
var aarFileAsset = AssetDatabase.FindAssets(aarName, new[] { AppCenterSettingsContext.AppCenterPath + "/Plugins/Android" });
|
||||
if (aarFileAsset.Length == 0)
|
||||
{
|
||||
Debug.LogWarning("Failed to link " + moduleName + ", file `" + aarName + "` is not found");
|
||||
return;
|
||||
}
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(aarFileAsset[0]);
|
||||
var importer = AssetImporter.GetAtPath(assetPath) as PluginImporter;
|
||||
if (importer != null)
|
||||
{
|
||||
Debug.Log (moduleName + " is " + (isEnabled ? "" : "not ") + "enabled. " +
|
||||
(isEnabled ? "Linking " : "Unlinking ") + aarName);
|
||||
importer.SetCompatibleWithPlatform(BuildTarget.Android, isEnabled);
|
||||
importer.SaveAndReimport();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
13
Assets/AppCenter/Editor/AppCenterPreBuild.cs.meta
Normal file
13
Assets/AppCenter/Editor/AppCenterPreBuild.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16e4e6da5f50549cfb7ca7a683d8ae8f
|
||||
timeCreated: 1513203132
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Assets/AppCenter/Editor/AppCenterSettingsContext.cs
Normal file
86
Assets/AppCenter/Editor/AppCenterSettingsContext.cs
Normal file
@ -0,0 +1,86 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
public class AppCenterSettingsContext : ScriptableObject
|
||||
{
|
||||
private static string appCenterPath;
|
||||
private static readonly string SettingsPath = AppCenterPath + "/AppCenterSettings.asset";
|
||||
private static readonly string AdvancedSettingsPath = AppCenterPath + "/AppCenterSettingsAdvanced.asset";
|
||||
public static string AppCenterPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(appCenterPath))
|
||||
{
|
||||
appCenterPath = FindSubfolderPath("Assets", "AppCenter");
|
||||
}
|
||||
return appCenterPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static AppCenterSettings SettingsInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
// No need to lock because this can only be accessed from the main thread.
|
||||
var instance = AssetDatabase.LoadAssetAtPath<AppCenterSettings>(SettingsPath);
|
||||
if (instance == null)
|
||||
{
|
||||
instance = CreateInstance<AppCenterSettings>();
|
||||
AssetDatabase.CreateAsset(instance, SettingsPath);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static AppCenterSettingsAdvanced SettingsInstanceAdvanced
|
||||
{
|
||||
get
|
||||
{
|
||||
// No need to lock because this can only be accessed from the main thread.
|
||||
return AssetDatabase.LoadAssetAtPath<AppCenterSettingsAdvanced>(AdvancedSettingsPath);
|
||||
}
|
||||
}
|
||||
|
||||
private static string FindSubfolderPath(string parentFolder, string searchFolder)
|
||||
{
|
||||
string[] folders = AssetDatabase.GetSubFolders(parentFolder);
|
||||
string resultFolder = folders.FirstOrDefault(folder => (new DirectoryInfo(folder)).Name == searchFolder);
|
||||
if (string.IsNullOrEmpty(resultFolder) && folders.Length > 0)
|
||||
{
|
||||
string temp;
|
||||
for (int i = 0; i < folders.Length; i++)
|
||||
{
|
||||
temp = FindSubfolderPath(folders[i], searchFolder);
|
||||
if (!string.IsNullOrEmpty(temp))
|
||||
{
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultFolder;
|
||||
}
|
||||
|
||||
public static AppCenterSettingsAdvanced CreateSettingsInstanceAdvanced()
|
||||
{
|
||||
var instance = AssetDatabase.LoadAssetAtPath<AppCenterSettingsAdvanced>(AdvancedSettingsPath);
|
||||
if (instance == null)
|
||||
{
|
||||
instance = CreateInstance<AppCenterSettingsAdvanced>();
|
||||
AssetDatabase.CreateAsset(instance, AdvancedSettingsPath);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void DeleteSettingsInstanceAdvanced()
|
||||
{
|
||||
AssetDatabase.DeleteAsset(AdvancedSettingsPath);
|
||||
}
|
||||
}
|
||||
13
Assets/AppCenter/Editor/AppCenterSettingsContext.cs.meta
Normal file
13
Assets/AppCenter/Editor/AppCenterSettingsContext.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2039654418774fd1a596ae0de6ec117
|
||||
timeCreated: 1513203491
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
58
Assets/AppCenter/Editor/AppCenterSettingsEditor.cs
Normal file
58
Assets/AppCenter/Editor/AppCenterSettingsEditor.cs
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Microsoft.AppCenter.Unity;
|
||||
|
||||
[CustomEditor(typeof(AppCenterSettings))]
|
||||
public class AppCenterSettingsEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
// Draw app secrets.
|
||||
Header("App Secrets");
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("iOSAppSecret"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AndroidAppSecret"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UWPAppSecret"));
|
||||
|
||||
// Draw modules.
|
||||
if (AppCenter.Analytics != null)
|
||||
{
|
||||
Header("Analytics");
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UseAnalytics"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("MaxStorageSize"));
|
||||
}
|
||||
if (AppCenter.Crashes != null)
|
||||
{
|
||||
Header("Crashes");
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UseCrashes"));
|
||||
}
|
||||
if (AppCenter.Distribute != null)
|
||||
{
|
||||
Header("Distribute");
|
||||
var serializedProperty = serializedObject.FindProperty("UseDistribute");
|
||||
EditorGUILayout.PropertyField(serializedProperty);
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("UpdateTrack"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AutomaticCheckForUpdate"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("EnableDistributeForDebuggableBuild"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("CustomApiUrl"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("CustomInstallUrl"));
|
||||
}
|
||||
|
||||
// Draw other.
|
||||
Header("Other Setup");
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("InitialLogLevel"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("CustomLogUrl"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("AllowNetworkRequests"));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static void Header(string label)
|
||||
{
|
||||
GUILayout.Label(label, EditorStyles.boldLabel);
|
||||
GUILayout.Space(-4);
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/Editor/AppCenterSettingsEditor.cs.meta
Normal file
12
Assets/AppCenter/Editor/AppCenterSettingsEditor.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8247f056cc059c4aa3d9b57058f5d64
|
||||
timeCreated: 1502269651
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/AppCenter/Editor/AppCenterSettingsEditorAdvanced.cs
Normal file
20
Assets/AppCenter/Editor/AppCenterSettingsEditorAdvanced.cs
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(AppCenterSettingsAdvanced))]
|
||||
public class AppCenterSettingsEditorAdvanced : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("TransmissionTargetToken"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("StartAndroidNativeSDKFromAppCenterBehavior"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("StartIOSNativeSDKFromAppCenterBehavior"), new GUIContent("Start iOS Native SDK From App Center Behavior"));
|
||||
//The following line can be useful if you want to be able to configure StartupType from AppCenter Behaviour Advanced.
|
||||
//EditorGUILayout.PropertyField(serializedObject.FindProperty("AppCenterStartupType"));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a11f2b13c794884191a36df20b65b1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
140
Assets/AppCenter/Editor/AppCenterSettingsMakerAndroid.cs
Normal file
140
Assets/AppCenter/Editor/AppCenterSettingsMakerAndroid.cs
Normal file
@ -0,0 +1,140 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
public class AppCenterSettingsMakerAndroid : IAppCenterSettingsMaker
|
||||
{
|
||||
private const string AppSecretKey = "appcenter_app_secret";
|
||||
private const string AllowNetworkRequestsKey = "allow_network_requests";
|
||||
private const string TransmissionTargetTokenKey = "appcenter_transmission_target_token";
|
||||
private const string CustomLogUrlKey = "appcenter_custom_log_url";
|
||||
private const string UseCustomLogUrlKey = "appcenter_use_custom_log_url";
|
||||
private const string InitialLogLevelKey = "appcenter_initial_log_level";
|
||||
private const string StartupTypeKey = "appcenter_startup_type";
|
||||
private const string UseCrashesKey = "appcenter_use_crashes";
|
||||
private const string UseAnalyticsKey = "appcenter_use_analytics";
|
||||
private const string UseDistributeKey = "appcenter_use_distribute";
|
||||
private const string DistributeDisableAutomaticCheckForUpdateKey = "appcenter_distribute_disable_automatic_check_for_update";
|
||||
private const string CustomApiUrlKey = "appcenter_custom_api_url";
|
||||
private const string UseCustomApiUrlKey = "appcenter_use_custom_api_url";
|
||||
private const string CustomInstallUrlKey = "appcenter_custom_install_url";
|
||||
private const string UseCustomInstallUrlKey = "appcenter_use_custom_install_url";
|
||||
private const string MaxStorageSizeKey = "appcenter_max_storage_size";
|
||||
private const string UpdateTrackKey = "appcenter_update_track";
|
||||
private const string EnableDistributeForDebuggableBuildKey = "appcenter_enable_distribute_for_debuggable_build";
|
||||
|
||||
private readonly IDictionary<string, string> _resourceValues = new Dictionary<string, string>();
|
||||
|
||||
public void SetLogLevel(int logLevel)
|
||||
{
|
||||
_resourceValues[InitialLogLevelKey] = logLevel.ToString();
|
||||
}
|
||||
|
||||
public void SetStartupType(int startupType)
|
||||
{
|
||||
_resourceValues[StartupTypeKey] = startupType.ToString();
|
||||
}
|
||||
|
||||
public void SetUpdateTrack(int updateTrack)
|
||||
{
|
||||
_resourceValues[UpdateTrackKey] = updateTrack.ToString();
|
||||
}
|
||||
|
||||
public void SetLogUrl(string logUrl)
|
||||
{
|
||||
_resourceValues[CustomLogUrlKey] = logUrl;
|
||||
_resourceValues[UseCustomLogUrlKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void IsAllowNetworkRequests(bool isAllowed)
|
||||
{
|
||||
_resourceValues[AllowNetworkRequestsKey] = isAllowed.ToString();
|
||||
}
|
||||
|
||||
public void SetAppSecret(AppCenterSettings settings)
|
||||
{
|
||||
_resourceValues[AppSecretKey] = settings.AndroidAppSecret;
|
||||
}
|
||||
|
||||
public void SetTransmissionTargetToken(string transmissionTargetToken)
|
||||
{
|
||||
_resourceValues[TransmissionTargetTokenKey] = transmissionTargetToken;
|
||||
}
|
||||
|
||||
public void StartCrashesClass()
|
||||
{
|
||||
_resourceValues[UseCrashesKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void StartAnalyticsClass()
|
||||
{
|
||||
_resourceValues[UseAnalyticsKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void StartDistributeClass()
|
||||
{
|
||||
_resourceValues[UseDistributeKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void SetDistributeDisableAutomaticCheckForUpdate()
|
||||
{
|
||||
_resourceValues[DistributeDisableAutomaticCheckForUpdateKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void SetApiUrl(string apiUrl)
|
||||
{
|
||||
_resourceValues[CustomApiUrlKey] = apiUrl;
|
||||
_resourceValues[UseCustomApiUrlKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void SetInstallUrl(string installUrl)
|
||||
{
|
||||
_resourceValues[CustomInstallUrlKey] = installUrl;
|
||||
_resourceValues[UseCustomInstallUrlKey] = true.ToString();
|
||||
}
|
||||
|
||||
public void SetMaxStorageSize(long size)
|
||||
{
|
||||
_resourceValues[MaxStorageSizeKey] = size.ToString();
|
||||
}
|
||||
|
||||
public void CommitSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public void CommitSettings(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
XmlResourceHelper.WriteXmlResource(filePath, _resourceValues);
|
||||
}
|
||||
|
||||
public bool IsStartFromAppCenterBehavior(AppCenterSettingsAdvanced advancedSettings)
|
||||
{
|
||||
return advancedSettings.StartAndroidNativeSDKFromAppCenterBehavior;
|
||||
}
|
||||
|
||||
public bool IsAnalyticsAvailable()
|
||||
{
|
||||
return File.Exists(AppCenterSettingsContext.AppCenterPath + "/Plugins/Android/appcenter-analytics-release.aar");
|
||||
}
|
||||
|
||||
public bool IsCrashesAvailable()
|
||||
{
|
||||
return File.Exists(AppCenterSettingsContext.AppCenterPath + "/Plugins/Android/appcenter-crashes-release.aar");
|
||||
}
|
||||
|
||||
public bool IsDistributeAvailable()
|
||||
{
|
||||
return File.Exists(AppCenterSettingsContext.AppCenterPath + "/Plugins/Android/appcenter-distribute-release.aar");
|
||||
}
|
||||
|
||||
public void SetShouldEnableDistributeForDebuggableBuild()
|
||||
{
|
||||
_resourceValues[EnableDistributeForDebuggableBuildKey] = true.ToString();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b2133faca91a47b49acd4d0fe6e076f
|
||||
timeCreated: 1502322233
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
150
Assets/AppCenter/Editor/AppCenterSettingsMakerIos.cs
Normal file
150
Assets/AppCenter/Editor/AppCenterSettingsMakerIos.cs
Normal file
@ -0,0 +1,150 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
|
||||
public class AppCenterSettingsMakerIos : IAppCenterSettingsMaker
|
||||
{
|
||||
private static readonly string TemplateFilePath = AppCenterSettingsContext.AppCenterPath + "/Plugins/iOS/Core/AppCenterStarter.original";
|
||||
private static readonly string TargetFilePath = AppCenterSettingsContext.AppCenterPath + "/Plugins/iOS/Core/AppCenterStarter.m";
|
||||
private const string AppSecretSearchText = "appcenter-app-secret";
|
||||
private const string AllowNetworkRequestsText = "allow-network-requests";
|
||||
private const string TransmissionTargetTokenSearchText = "appcenter-transmission-target-token";
|
||||
private const string LogUrlSearchText = "custom-log-url";
|
||||
private const string LogUrlToken = "APPCENTER_UNITY_USE_CUSTOM_LOG_URL";
|
||||
private const string LogLevelSearchText = "0/*LOG_LEVEL*/";
|
||||
private const string StartupTypeSearchText = "0/*STARTUP_TYPE*/";
|
||||
private const string UseCrashesToken = "APPCENTER_UNITY_USE_CRASHES";
|
||||
private const string UseAnalyticsToken = "APPCENTER_UNITY_USE_ANALYTICS";
|
||||
private const string UseDistributeToken = "APPCENTER_UNITY_USE_DISTRIBUTE";
|
||||
private const string DistributeDisableAutomaticCheckForUpdateToken = "APPCENTER_DISTRIBUTE_DISABLE_AUTOMATIC_CHECK_FOR_UPDATE";
|
||||
private const string ApiUrlSearchText = "custom-api-url";
|
||||
private const string ApiUrlToken = "APPCENTER_UNITY_USE_CUSTOM_API_URL";
|
||||
private const string InstallUrlSearchText = "custom-install-url";
|
||||
private const string InstallUrlToken = "APPCENTER_UNITY_USE_CUSTOM_INSTALL_URL";
|
||||
private const string UseCustomMaxStorageSize = "APPCENTER_USE_CUSTOM_MAX_STORAGE_SIZE";
|
||||
private const string MaxStorageSize = "APPCENTER_MAX_STORAGE_SIZE";
|
||||
private const string UpdateTrackSearchText = "1 /*UPDATE_TRACK*/";
|
||||
|
||||
private string _loaderFileText;
|
||||
private bool _enableDistributeForDebuggableBuild;
|
||||
|
||||
public AppCenterSettingsMakerIos()
|
||||
{
|
||||
_loaderFileText = File.ReadAllText(TemplateFilePath);
|
||||
}
|
||||
|
||||
public void SetLogLevel(int logLevel)
|
||||
{
|
||||
_loaderFileText = _loaderFileText.Replace(LogLevelSearchText, logLevel.ToString());
|
||||
}
|
||||
|
||||
public void IsAllowNetworkRequests(bool isAllowed)
|
||||
{
|
||||
_loaderFileText = _loaderFileText.Replace(AllowNetworkRequestsText, isAllowed ? "YES" : "NO");
|
||||
}
|
||||
|
||||
public void SetStartupType(int startupType)
|
||||
{
|
||||
_loaderFileText = _loaderFileText.Replace(StartupTypeSearchText, startupType.ToString());
|
||||
}
|
||||
|
||||
public void SetLogUrl(string logUrl)
|
||||
{
|
||||
AddToken(LogUrlToken);
|
||||
_loaderFileText = _loaderFileText.Replace(LogUrlSearchText, logUrl);
|
||||
}
|
||||
|
||||
public void SetAppSecret(AppCenterSettings settings)
|
||||
{
|
||||
_loaderFileText = _loaderFileText.Replace(AppSecretSearchText, settings.iOSAppSecret);
|
||||
}
|
||||
|
||||
public void SetTransmissionTargetToken(string transmissionTargetToken)
|
||||
{
|
||||
_loaderFileText = _loaderFileText.Replace(TransmissionTargetTokenSearchText, transmissionTargetToken);
|
||||
}
|
||||
|
||||
public void StartCrashesClass()
|
||||
{
|
||||
AddToken(UseCrashesToken);
|
||||
}
|
||||
|
||||
public void StartDistributeClass()
|
||||
{
|
||||
if (_enableDistributeForDebuggableBuild || !EditorUserBuildSettings.development)
|
||||
{
|
||||
AddToken(UseDistributeToken);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAnalyticsClass()
|
||||
{
|
||||
AddToken(UseAnalyticsToken);
|
||||
}
|
||||
|
||||
public void SetApiUrl(string apiUrl)
|
||||
{
|
||||
AddToken(ApiUrlToken);
|
||||
_loaderFileText = _loaderFileText.Replace(ApiUrlSearchText, apiUrl);
|
||||
}
|
||||
|
||||
public void SetInstallUrl(string installUrl)
|
||||
{
|
||||
AddToken(InstallUrlToken);
|
||||
_loaderFileText = _loaderFileText.Replace(InstallUrlSearchText, installUrl);
|
||||
}
|
||||
|
||||
public void CommitSettings()
|
||||
{
|
||||
File.WriteAllText(TargetFilePath, _loaderFileText);
|
||||
}
|
||||
|
||||
public void SetMaxStorageSize(long size)
|
||||
{
|
||||
AddToken(UseCustomMaxStorageSize);
|
||||
_loaderFileText = _loaderFileText.Replace(MaxStorageSize, size.ToString());
|
||||
}
|
||||
|
||||
private void AddToken(string token)
|
||||
{
|
||||
var tokenText = "#define " + token + "\n";
|
||||
_loaderFileText = tokenText + _loaderFileText;
|
||||
}
|
||||
|
||||
public bool IsStartFromAppCenterBehavior(AppCenterSettingsAdvanced advancedSettings)
|
||||
{
|
||||
return advancedSettings.StartIOSNativeSDKFromAppCenterBehavior;
|
||||
}
|
||||
|
||||
public bool IsAnalyticsAvailable()
|
||||
{
|
||||
return Directory.Exists(AppCenterSettingsContext.AppCenterPath + "/Plugins/iOS/Analytics");
|
||||
}
|
||||
|
||||
public bool IsCrashesAvailable()
|
||||
{
|
||||
return Directory.Exists(AppCenterSettingsContext.AppCenterPath + "/Plugins/iOS/Crashes");
|
||||
}
|
||||
|
||||
public bool IsDistributeAvailable()
|
||||
{
|
||||
return Directory.Exists(AppCenterSettingsContext.AppCenterPath + "/Plugins/iOS/Distribute");
|
||||
}
|
||||
|
||||
public void SetShouldEnableDistributeForDebuggableBuild()
|
||||
{
|
||||
_enableDistributeForDebuggableBuild = true;
|
||||
}
|
||||
|
||||
public void SetDistributeDisableAutomaticCheckForUpdate()
|
||||
{
|
||||
AddToken(DistributeDisableAutomaticCheckForUpdateToken);
|
||||
}
|
||||
|
||||
public void SetUpdateTrack(int updateTrack)
|
||||
{
|
||||
_loaderFileText = _loaderFileText.Replace(UpdateTrackSearchText, updateTrack.ToString());
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/Editor/AppCenterSettingsMakerIos.cs.meta
Normal file
12
Assets/AppCenter/Editor/AppCenterSettingsMakerIos.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb87d249dd7a048688f34b63e118a7b0
|
||||
timeCreated: 1502216315
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/AppCenter/Editor/AppSecretDrawer.cs
Normal file
19
Assets/AppCenter/Editor/AppSecretDrawer.cs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(AppSecretAttribute))]
|
||||
public class AppSecretDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var name = ((AppSecretAttribute) attribute).Name;
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
label.text = name;
|
||||
}
|
||||
EditorGUI.PropertyField(position, property, label);
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/Editor/AppSecretDrawer.cs.meta
Normal file
12
Assets/AppCenter/Editor/AppSecretDrawer.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 119814cc89d1e4652975a06e6df567c6
|
||||
timeCreated: 1504046963
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
12
Assets/AppCenter/Editor/ApplicationIdHelper.cs
Normal file
12
Assets/AppCenter/Editor/ApplicationIdHelper.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEditor;
|
||||
|
||||
public static class ApplicationIdHelper
|
||||
{
|
||||
public static string GetApplicationId()
|
||||
{
|
||||
return PlayerSettings.applicationIdentifier;
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/Editor/ApplicationIdHelper.cs.meta
Normal file
12
Assets/AppCenter/Editor/ApplicationIdHelper.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c39732e4de5a34bfbbda09c28c8e7f9f
|
||||
timeCreated: 1503349438
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/AppCenter/Editor/CustomDropDownPropertyDrawer.cs
Normal file
39
Assets/AppCenter/Editor/CustomDropDownPropertyDrawer.cs
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomPropertyDrawer(typeof(CustomDropDownPropertyAttribute))]
|
||||
public class CustomDropDownPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
bool _initialized = false;
|
||||
object[] _attributes = null;
|
||||
Dictionary<string, int> _optionsDictionary = new Dictionary<string, int>();
|
||||
string[] _options = null;
|
||||
int _selectedIndex = 0;
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
_attributes = fieldInfo.GetCustomAttributes(typeof(CustomDropDownPropertyAttribute), false);
|
||||
foreach (var itemAttribute in _attributes)
|
||||
{
|
||||
var customPropertyAttribute = itemAttribute as CustomDropDownPropertyAttribute;
|
||||
_optionsDictionary.Add(customPropertyAttribute.SelectedKey, customPropertyAttribute.SelectedValue);
|
||||
if (customPropertyAttribute.SelectedValue == AppCenterSettingsContext.SettingsInstance.UpdateTrack)
|
||||
{
|
||||
_selectedIndex = ArrayUtility.IndexOf(_attributes, itemAttribute);
|
||||
}
|
||||
}
|
||||
_options = _optionsDictionary.Keys.ToArray();
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
_selectedIndex = EditorGUI.Popup(position, property.displayName, _selectedIndex, _options);
|
||||
property.intValue = _optionsDictionary[_options[_selectedIndex]];
|
||||
}
|
||||
}
|
||||
11
Assets/AppCenter/Editor/CustomDropDownPropertyDrawer.cs.meta
Normal file
11
Assets/AppCenter/Editor/CustomDropDownPropertyDrawer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0e8996e972247549b62c85a8d7aa869
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/AppCenter/Editor/CustomUrlPropertyDrawer.cs
Normal file
43
Assets/AppCenter/Editor/CustomUrlPropertyDrawer.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(CustomUrlProperty))]
|
||||
public class CustomUrlPropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
property.Next(true);
|
||||
var urlName = property.stringValue;
|
||||
var useLabel = new GUIContent("Use Custom " + urlName + " URL");
|
||||
var urlLabel = new GUIContent("Custom " + urlName + " URL");
|
||||
|
||||
// Though the property may have double height, each child should have
|
||||
// half that height.
|
||||
position.height = EditorGUIUtility.singleLineHeight;
|
||||
property.Next(false);
|
||||
EditorGUI.PropertyField(position, property, useLabel);
|
||||
if (property.boolValue)
|
||||
{
|
||||
property.Next(false);
|
||||
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(position, property, urlLabel);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// If "set custom log url" is true, need to make room for the text field.
|
||||
property.Next(true);
|
||||
property.Next(false);
|
||||
|
||||
var height = base.GetPropertyHeight(property, label);
|
||||
if (property.boolValue)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
12
Assets/AppCenter/Editor/CustomUrlPropertyDrawer.cs.meta
Normal file
12
Assets/AppCenter/Editor/CustomUrlPropertyDrawer.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebeca1d941dd04282895d881deecbc6c
|
||||
timeCreated: 1504725583
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/AppCenter/Editor/IAppCenterSettingsMaker.cs
Normal file
26
Assets/AppCenter/Editor/IAppCenterSettingsMaker.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
public interface IAppCenterSettingsMaker
|
||||
{
|
||||
bool IsAnalyticsAvailable();
|
||||
bool IsCrashesAvailable();
|
||||
void IsAllowNetworkRequests(bool isAllowed);
|
||||
bool IsDistributeAvailable();
|
||||
void StartAnalyticsClass();
|
||||
void StartCrashesClass();
|
||||
void StartDistributeClass();
|
||||
void SetAppSecret(AppCenterSettings settings);
|
||||
void SetTransmissionTargetToken(string transmissionTargetToken);
|
||||
void SetLogLevel(int logLevel);
|
||||
bool IsStartFromAppCenterBehavior(AppCenterSettingsAdvanced advancedSettings);
|
||||
void SetStartupType(int startupType);
|
||||
void SetLogUrl(string logUrl);
|
||||
void SetApiUrl(string apiUrl);
|
||||
void SetInstallUrl(string installUrl);
|
||||
void SetMaxStorageSize(long size);
|
||||
void CommitSettings();
|
||||
void SetShouldEnableDistributeForDebuggableBuild();
|
||||
void SetDistributeDisableAutomaticCheckForUpdate();
|
||||
void SetUpdateTrack(int updateTrack);
|
||||
}
|
||||
11
Assets/AppCenter/Editor/IAppCenterSettingsMaker.cs.meta
Normal file
11
Assets/AppCenter/Editor/IAppCenterSettingsMaker.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a40c6c75c7d49cd4ab84b0d6d68a509f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/AppCenter/Editor/MaxStorageSizePropertyDrawer.cs
Normal file
35
Assets/AppCenter/Editor/MaxStorageSizePropertyDrawer.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
[CustomPropertyDrawer(typeof(MaxStorageSizeProperty))]
|
||||
public class MaxStorageSizePropertyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var useLabel = new GUIContent("Use Custom Max Storage Size");
|
||||
var urlLabel = new GUIContent("Max Storage Size Bytes");
|
||||
position.height = EditorGUIUtility.singleLineHeight; // Though the property may have double height, each child should have half that height.
|
||||
property.Next(true);
|
||||
EditorGUI.PropertyField(position, property, useLabel);
|
||||
if (property.boolValue)
|
||||
{
|
||||
property.Next(false);
|
||||
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(position, property, urlLabel);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
property.Next(true); // If "Use Custom Max Storage Size" is true, need to make room for the text field.
|
||||
var height = base.GetPropertyHeight(property, label);
|
||||
if (property.boolValue)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
11
Assets/AppCenter/Editor/MaxStorageSizePropertyDrawer.cs.meta
Normal file
11
Assets/AppCenter/Editor/MaxStorageSizePropertyDrawer.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 428e5cf118c809a40b0fbc4b93d77e60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
103
Assets/AppCenter/Editor/PBXProjectWrapper.cs
Normal file
103
Assets/AppCenter/Editor/PBXProjectWrapper.cs
Normal file
@ -0,0 +1,103 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
/*
|
||||
* Wrapper class for PBXProject that invokes methods via reflection. Needed
|
||||
* because there are cases when conditional compilation symbols are not
|
||||
* defined soon enough to use the class directly. Using the class directly
|
||||
* can cause problems on Windows machines that don't have the iOS build
|
||||
* tool installed.
|
||||
*/
|
||||
public class PBXProjectWrapper
|
||||
{
|
||||
private static readonly Type PBXProjectType;
|
||||
private object _pbxProject;
|
||||
private string _projectPath;
|
||||
|
||||
static PBXProjectWrapper()
|
||||
{
|
||||
var xcExtensionsAssembly = Assembly.Load("UnityEditor.iOS.Extensions.Xcode");
|
||||
if (xcExtensionsAssembly != null)
|
||||
{
|
||||
PBXProjectType = xcExtensionsAssembly.GetType("UnityEditor.iOS.Xcode.PBXProject");
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetUnityTargetName()
|
||||
{
|
||||
var flags = BindingFlags.Public | BindingFlags.Static;
|
||||
return PBXProjectType.GetMethod("GetUnityTargetName", flags)
|
||||
.Invoke(PBXProjectType, null) as string;
|
||||
}
|
||||
|
||||
public string GetUnityTargetGuid()
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
return PBXProjectType.GetMethod("GetUnityFrameworkTargetGuid")
|
||||
.Invoke(_pbxProject, null).ToString();
|
||||
#else
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool PBXProjectIsAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
return PBXProjectType != null;
|
||||
}
|
||||
}
|
||||
|
||||
public string ProjectPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return _projectPath;
|
||||
}
|
||||
}
|
||||
|
||||
public PBXProjectWrapper(string pathToBuiltProject)
|
||||
{
|
||||
var flags = BindingFlags.Public | BindingFlags.Static;
|
||||
var arguments = new object[] { pathToBuiltProject };
|
||||
_projectPath = PBXProjectType.GetMethod("GetPBXProjectPath", flags)
|
||||
.Invoke(PBXProjectType, arguments) as string;
|
||||
_pbxProject = PBXProjectType.GetConstructor(Type.EmptyTypes).Invoke(null);
|
||||
PBXProjectType.GetMethod("ReadFromFile").Invoke(_pbxProject, new[] { _projectPath });
|
||||
}
|
||||
|
||||
public void WriteToFile()
|
||||
{
|
||||
PBXProjectType.GetMethod("WriteToFile").Invoke(_pbxProject, new[] { _projectPath });
|
||||
}
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
public void AddBuildProperty(string name, string value, bool toFrameworkTarget = false)
|
||||
#else
|
||||
public void AddBuildProperty(string name, string value)
|
||||
#endif
|
||||
{
|
||||
object targetGuid;
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
targetGuid = PBXProjectType.GetMethod("GetUnityMainTargetGuid")
|
||||
.Invoke(_pbxProject, null);
|
||||
if (toFrameworkTarget)
|
||||
{
|
||||
object frameworkTarget = PBXProjectType.GetMethod("GetUnityFrameworkTargetGuid").Invoke(_pbxProject, null);
|
||||
PBXProjectType.GetMethod("AddBuildProperty", new[] { typeof(string), typeof(string), typeof(string) })
|
||||
.Invoke(_pbxProject, new[] { frameworkTarget, name, value });
|
||||
}
|
||||
#else
|
||||
var targetName = GetUnityTargetName();
|
||||
targetGuid = PBXProjectType.GetMethod("TargetGuidByName")
|
||||
.Invoke(_pbxProject, new object[] { targetName });
|
||||
#endif
|
||||
PBXProjectType.GetMethod("AddBuildProperty",
|
||||
new[] { typeof(string), typeof(string), typeof(string) })
|
||||
.Invoke(_pbxProject,
|
||||
new[] { targetGuid, name, value });
|
||||
}
|
||||
}
|
||||
13
Assets/AppCenter/Editor/PBXProjectWrapper.cs.meta
Normal file
13
Assets/AppCenter/Editor/PBXProjectWrapper.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4e4b5327bd6d4fa1b30a0da2ba6ae46
|
||||
timeCreated: 1513288156
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/AppCenter/Editor/PlistDocumentWrapper.cs
Normal file
46
Assets/AppCenter/Editor/PlistDocumentWrapper.cs
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
public class PlistDocumentWrapper
|
||||
{
|
||||
private object _plistDocument;
|
||||
private string _path;
|
||||
private static readonly Type PlistDocumentType;
|
||||
|
||||
static PlistDocumentWrapper()
|
||||
{
|
||||
var xcExtensionsAssembly = Assembly.Load("UnityEditor.iOS.Extensions.Xcode");
|
||||
if (xcExtensionsAssembly != null)
|
||||
{
|
||||
PlistDocumentType = xcExtensionsAssembly.GetType("UnityEditor.iOS.Xcode.PlistDocument");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool PlistDocumentIsAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
return PlistDocumentType != null;
|
||||
}
|
||||
}
|
||||
|
||||
public PlistDocumentWrapper(string path)
|
||||
{
|
||||
_path = path;
|
||||
_plistDocument = PlistDocumentType.GetConstructor(Type.EmptyTypes).Invoke(null);
|
||||
PlistDocumentType.GetMethod("ReadFromFile").Invoke(_plistDocument, new[] { _path });
|
||||
}
|
||||
|
||||
public object GetRoot()
|
||||
{
|
||||
return PlistDocumentType.GetField("root").GetValue(_plistDocument);
|
||||
}
|
||||
|
||||
public void WriteToFile()
|
||||
{
|
||||
PlistDocumentType.GetMethod("WriteToFile").Invoke(_plistDocument, new[] { _path });
|
||||
}
|
||||
}
|
||||
13
Assets/AppCenter/Editor/PlistDocumentWrapper.cs.meta
Normal file
13
Assets/AppCenter/Editor/PlistDocumentWrapper.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fce65b4e1d6646dda661bf55f78e3f6
|
||||
timeCreated: 1513288156
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/AppCenter/Editor/ProjectCapabilityManagerWrapper.cs
Normal file
53
Assets/AppCenter/Editor/ProjectCapabilityManagerWrapper.cs
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
public class ProjectCapabilityManagerWrapper
|
||||
{
|
||||
private static readonly Type ProjectCapabilityManagerType;
|
||||
private object _capabilityManager;
|
||||
|
||||
static ProjectCapabilityManagerWrapper()
|
||||
{
|
||||
var xcExtensionsAssembly = Assembly.Load("UnityEditor.iOS.Extensions.Xcode");
|
||||
if (xcExtensionsAssembly != null)
|
||||
{
|
||||
ProjectCapabilityManagerType = xcExtensionsAssembly.GetType("UnityEditor.iOS.Xcode.ProjectCapabilityManager");
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRemoteNotificationsToBackgroundModes()
|
||||
{
|
||||
var backgroundModesEnumType = ProjectCapabilityManagerType.Assembly.GetType("UnityEditor.iOS.Xcode.BackgroundModesOptions");
|
||||
var remoteNotifEnum = Enum.Parse(backgroundModesEnumType, "RemoteNotifications");
|
||||
ProjectCapabilityManagerType.GetMethod("AddBackgroundModes").Invoke(_capabilityManager, new object[] { remoteNotifEnum });
|
||||
}
|
||||
|
||||
public static bool ProjectCapabilityManagerIsAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
return ProjectCapabilityManagerType != null;
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectCapabilityManagerWrapper(string projectPath, string targetName, string targetGuid)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
_capabilityManager = ProjectCapabilityManagerType
|
||||
.GetConstructor(new[] { typeof(string), typeof(string), typeof(string), typeof(string) })
|
||||
.Invoke(new object[] { projectPath, targetName + ".entitlements", targetName, targetGuid });
|
||||
#else
|
||||
_capabilityManager = ProjectCapabilityManagerType
|
||||
.GetConstructor(new[] { typeof(string), typeof(string), typeof(string)})
|
||||
.Invoke(new object[] { projectPath, targetName + ".entitlements", targetName });
|
||||
#endif
|
||||
}
|
||||
|
||||
public void WriteToFile()
|
||||
{
|
||||
ProjectCapabilityManagerType.GetMethod("WriteToFile").Invoke(_capabilityManager, null);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ca2e2a428dbc432c930ec7a5b186fba
|
||||
timeCreated: 1513288156
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/AppCenter/Editor/XmlResourceHelper.cs
Normal file
40
Assets/AppCenter/Editor/XmlResourceHelper.cs
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
public static class XmlResourceHelper
|
||||
{
|
||||
public static void WriteXmlResource(string path, IDictionary<string, string> resourceValues)
|
||||
{
|
||||
var xws = new XmlWriterSettings
|
||||
{
|
||||
Indent = true
|
||||
};
|
||||
using (var sw = File.Create(path))
|
||||
using (var xw = XmlWriter.Create(sw, xws))
|
||||
{
|
||||
xw.WriteStartDocument();
|
||||
xw.WriteStartElement("resources");
|
||||
|
||||
foreach (var kvp in resourceValues)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(kvp.Value))
|
||||
{
|
||||
xw.WriteStartElement("string");
|
||||
xw.WriteAttributeString("name", kvp.Key);
|
||||
xw.WriteAttributeString("translatable", "false");
|
||||
xw.WriteString(kvp.Value);
|
||||
xw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
xw.WriteEndElement();
|
||||
xw.WriteEndDocument();
|
||||
xw.Flush();
|
||||
xw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/AppCenter/Editor/XmlResourceHelper.cs.meta
Normal file
13
Assets/AppCenter/Editor/XmlResourceHelper.cs.meta
Normal file
@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc5634190b21448b6bdeac14c833304c
|
||||
timeCreated: 1513106215
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/AppCenter/Plugins.meta
Normal file
8
Assets/AppCenter/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2b03a217b6ed8349b372a679a0f7aae
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/AppCenter/Plugins/Android.meta
Normal file
8
Assets/AppCenter/Plugins/Android.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afed194a733530a4eb52e6e0d76a80b1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/AppCenter/Plugins/Android/Utility.meta
Normal file
34
Assets/AppCenter/Plugins/Android/Utility.meta
Normal file
@ -0,0 +1,34 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65a57d979f383420a894f22dfe19f005
|
||||
folderAsset: yes
|
||||
timeCreated: 1498496047
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/AppCenter/Plugins/Android/Utility/AndroidUtility.cs
Normal file
43
Assets/AppCenter/Plugins/Android/Utility/AndroidUtility.cs
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.AppCenter.Plugins.Android.Utility
|
||||
{
|
||||
class AndroidUtility
|
||||
{
|
||||
private static AndroidJavaObject _context;
|
||||
private const string PREFS_NAME = "AppCenterUserPrefs";
|
||||
|
||||
public static AndroidJavaObject GetAndroidContext()
|
||||
{
|
||||
if (_context != null)
|
||||
{
|
||||
return _context;
|
||||
}
|
||||
var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
_context = activity.Call<AndroidJavaObject>("getApplicationContext");
|
||||
return _context;
|
||||
}
|
||||
|
||||
public static void SetPreferenceInt(string prefKey, int prefValue)
|
||||
{
|
||||
AndroidJavaObject context = GetAndroidContext();
|
||||
AndroidJavaObject sharedPreferences = context.Call<AndroidJavaObject>("getSharedPreferences", new object[] { PREFS_NAME, 0 });
|
||||
AndroidJavaObject editor = sharedPreferences.Call<AndroidJavaObject>("edit");
|
||||
editor = editor.Call<AndroidJavaObject>("putInt", new object[] { prefKey, prefValue });
|
||||
editor.Call("apply");
|
||||
}
|
||||
|
||||
public static void SetPreferenceString(string prefKey, string prefValue)
|
||||
{
|
||||
AndroidJavaObject context = GetAndroidContext();
|
||||
AndroidJavaObject sharedPreferences = context.Call<AndroidJavaObject>("getSharedPreferences", new object[] { PREFS_NAME, 0 });
|
||||
AndroidJavaObject editor = sharedPreferences.Call<AndroidJavaObject>("edit");
|
||||
editor = editor.Call<AndroidJavaObject>("putString", new object[] { prefKey, prefValue });
|
||||
editor.Call("apply");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7653ac593f8a4859bc75b4952e2a9dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/AppCenter/Plugins/Android/Utility/JavaDateHelper.cs
Normal file
49
Assets/AppCenter/Plugins/Android/Utility/JavaDateHelper.cs
Normal file
@ -0,0 +1,49 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Internal.Utility
|
||||
{
|
||||
public class JavaDateHelper
|
||||
{
|
||||
private const string DotNetDateFormat = "yyyy-MM-dd'T'HH:mm:ss.fffK";
|
||||
|
||||
private static AndroidJavaObject _javaDateFormatter;
|
||||
private static AndroidJavaObject JavaDateFormatter
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_javaDateFormatter == null)
|
||||
{
|
||||
_javaDateFormatter = new AndroidJavaObject("java.text.SimpleDateFormat", "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
}
|
||||
return _javaDateFormatter;
|
||||
}
|
||||
}
|
||||
|
||||
public static AndroidJavaObject DateTimeConvert(DateTime date)
|
||||
{
|
||||
// 'DotNetDateFormat' contains timezone info with time separator.
|
||||
// 'javaDateFormatter' uses date format with timezone info without time separator.
|
||||
// Time separator should be removed from date string before 'parse' call.
|
||||
var dateString = date.ToString(DotNetDateFormat);
|
||||
int separatorIndex = dateString.LastIndexOf(CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator);
|
||||
dateString = dateString.Remove(separatorIndex, 1);
|
||||
return JavaDateFormatter.Call<AndroidJavaObject>("parse", dateString);
|
||||
}
|
||||
|
||||
public static DateTimeOffset DateTimeConvert(AndroidJavaObject date)
|
||||
{
|
||||
// Unable to use DateTimeOffset.ParseExact(dateString, DotNetDateFormat, CultureInfo.InvariantCulture) here
|
||||
// because it throws "Invalid format string" exception
|
||||
var dateString = JavaDateFormatter.Call<string>("format", date);
|
||||
var dateTime = DateTime.ParseExact(dateString, DotNetDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
|
||||
return new DateTimeOffset(dateTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebd2662d8c212481b8ae72fe6be77873
|
||||
timeCreated: 1498578955
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/AppCenter/Plugins/Android/Utility/JavaNumberHelper.cs
Normal file
38
Assets/AppCenter/Plugins/Android/Utility/JavaNumberHelper.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Internal.Utility
|
||||
{
|
||||
public class JavaNumberHelper
|
||||
{
|
||||
public static AndroidJavaObject Convert(int val)
|
||||
{
|
||||
AndroidJavaObject javaInteger = new AndroidJavaObject("java.lang.Integer", val);
|
||||
return javaInteger;
|
||||
}
|
||||
|
||||
public static AndroidJavaObject Convert(long val)
|
||||
{
|
||||
AndroidJavaObject javaLong = new AndroidJavaObject("java.lang.Long", val);
|
||||
return javaLong;
|
||||
}
|
||||
|
||||
public static AndroidJavaObject Convert(float val)
|
||||
{
|
||||
AndroidJavaObject javaFloat = new AndroidJavaObject("java.lang.Float", val);
|
||||
return javaFloat;
|
||||
}
|
||||
|
||||
public static AndroidJavaObject Convert(double val)
|
||||
{
|
||||
AndroidJavaObject javaDouble = new AndroidJavaObject("java.lang.Double", val);
|
||||
return javaDouble;
|
||||
}
|
||||
|
||||
//TODO how to support decimal?
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcfb87d5b5fb94c77b4d361b4791a677
|
||||
timeCreated: 1498578955
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,46 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Internal.Utility
|
||||
{
|
||||
public class JavaStringMapHelper
|
||||
{
|
||||
public static Dictionary<string, string> ConvertFromJava(AndroidJavaObject map)
|
||||
{
|
||||
var keySet = map.Call<AndroidJavaObject>("keySet");
|
||||
var keyArray = keySet.Call<AndroidJavaObject>("toArray");
|
||||
string[] keys = AndroidJNIHelper.ConvertFromJNIArray<string[]>(keyArray.GetRawObject());
|
||||
var dictionary = new Dictionary<string, string>();
|
||||
foreach (var key in keys)
|
||||
{
|
||||
var val = map.Call<string>("get", key);
|
||||
dictionary[key] = val;
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public static AndroidJavaObject ConvertToJava(IDictionary<string, string> properties)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string[] keys = properties.Keys.ToArray();
|
||||
string[] values = properties.Values.ToArray();
|
||||
int count = properties.Count;
|
||||
var javaMap = new AndroidJavaObject("java.util.HashMap");
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
javaMap.Call<AndroidJavaObject>("put", keys[i], values[i]);
|
||||
}
|
||||
return javaMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80fb4bb7b657748d399b89f4367331e8
|
||||
timeCreated: 1498496048
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/AppCenter/Plugins/Android/Utility/archive.ps1
Normal file
21
Assets/AppCenter/Plugins/Android/Utility/archive.ps1
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT license.
|
||||
|
||||
param
|
||||
(
|
||||
[Parameter(Position=0, Mandatory = $false, HelpMessage="Source folder", ValueFromPipeline = $true)]
|
||||
$Source,
|
||||
[Parameter(Position=1, Mandatory = $false, HelpMessage="Destination file path", ValueFromPipeline = $true)]
|
||||
$Destination
|
||||
)
|
||||
|
||||
Try
|
||||
{
|
||||
Add-Type -assembly "system.io.compression.filesystem"
|
||||
[io.compression.zipfile]::CreateFromDirectory($Source, $Destination)
|
||||
}
|
||||
Catch
|
||||
{
|
||||
$Exc = $_.Exception.Message
|
||||
Write-Error "File $Destination was not created. Error: $Exc"
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||
guid: 27462eedb9e0e4dee8d0ff51fe4dee0d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
23
Assets/AppCenter/Plugins/Android/Utility/unarchive.ps1
Normal file
23
Assets/AppCenter/Plugins/Android/Utility/unarchive.ps1
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT license.
|
||||
|
||||
param
|
||||
(
|
||||
[Parameter(Position=0, Mandatory = $false, HelpMessage="Source file", ValueFromPipeline = $true)]
|
||||
$Source,
|
||||
[Parameter(Position=1, Mandatory = $false, HelpMessage="Destination path", ValueFromPipeline = $true)]
|
||||
$Destination
|
||||
)
|
||||
|
||||
New-Item -ItemType directory -Path $Destination
|
||||
|
||||
Try
|
||||
{
|
||||
Add-Type -assembly "system.io.compression.filesystem"
|
||||
[io.compression.zipfile]::ExtractToDirectory($Source, $Destination)
|
||||
}
|
||||
Catch
|
||||
{
|
||||
$Exc = $_.Exception.Message
|
||||
Write-Error "Folder $Destination was not created. Error: $Exc"
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fff91df92b854ad680ee28ba1c36fce
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/AppCenter/Plugins/Android/appcenter-analytics-release.aar
Normal file
BIN
Assets/AppCenter/Plugins/Android/appcenter-analytics-release.aar
Normal file
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f313f109a3454802b5cae94a72ee306
|
||||
timeCreated: 1504718816
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/AppCenter/Plugins/Android/appcenter-crashes-release.aar
Normal file
BIN
Assets/AppCenter/Plugins/Android/appcenter-crashes-release.aar
Normal file
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20e621e7423ed4dd4b6826b8dab0c7eb
|
||||
timeCreated: 1512463304
|
||||
licenseType: Free
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68c3a86f609b440b1b95a05639da7861
|
||||
timeCreated: 1504718816
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/AppCenter/Plugins/Android/appcenter-loader-release.aar
Normal file
BIN
Assets/AppCenter/Plugins/Android/appcenter-loader-release.aar
Normal file
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1865e2b19b6434dcf9e4f48f7208d7a0
|
||||
timeCreated: 1503351439
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/AppCenter/Plugins/Android/appcenter-release.aar
Normal file
BIN
Assets/AppCenter/Plugins/Android/appcenter-release.aar
Normal file
Binary file not shown.
33
Assets/AppCenter/Plugins/Android/appcenter-release.aar.meta
Normal file
33
Assets/AppCenter/Plugins/Android/appcenter-release.aar.meta
Normal file
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10c16a9d75c5c48cca25985ae8bf3ec6
|
||||
timeCreated: 1504718816
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/AppCenter/Plugins/AppCenterSDK.meta
Normal file
8
Assets/AppCenter/Plugins/AppCenterSDK.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4de8fbe7ed99aa245bf6616636b6c980
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/AppCenter/Plugins/AppCenterSDK/Analytics.meta
Normal file
8
Assets/AppCenter/Plugins/AppCenterSDK/Analytics.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3834fae7b40ff624cbea26abb8c648d4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3081e1f5b9e3f4598ba1d4ec33c30d17
|
||||
folderAsset: yes
|
||||
timeCreated: 1498059874
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,96 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics.Internal
|
||||
{
|
||||
class AnalyticsInternal
|
||||
{
|
||||
private static AndroidJavaClass _analytics = new AndroidJavaClass("com.microsoft.appcenter.analytics.Analytics");
|
||||
|
||||
public static void PrepareEventHandlers()
|
||||
{
|
||||
AppCenterBehavior.InitializedAppCenterAndServices += PostInitialize;
|
||||
}
|
||||
|
||||
private static void PostInitialize()
|
||||
{
|
||||
var instance = _analytics.CallStatic<AndroidJavaObject>("getInstance");
|
||||
AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
instance.Call("onActivityResumed", activity);
|
||||
}
|
||||
|
||||
public static void AddNativeType(List<IntPtr> nativeTypes)
|
||||
{
|
||||
nativeTypes.Add(AndroidJNI.FindClass("com/microsoft/appcenter/analytics/Analytics"));
|
||||
}
|
||||
|
||||
public static void TrackEvent(string eventName)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName);
|
||||
}
|
||||
|
||||
public static void TrackEvent(string eventName, int flags)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName, null, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, IDictionary<string, string> properties)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
_analytics.CallStatic("trackEvent", eventName, androidProperties);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, EventProperties properties)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName, properties.GetRawObject());
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, IDictionary<string, string> properties, int flags)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
_analytics.CallStatic("trackEvent", eventName, androidProperties, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, EventProperties properties, int flags)
|
||||
{
|
||||
_analytics.CallStatic("trackEvent", eventName, properties.GetRawObject(), flags);
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(bool isEnabled)
|
||||
{
|
||||
var future = _analytics.CallStatic<AndroidJavaObject>("setEnabled", isEnabled);
|
||||
return new AppCenterTask(future);
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync()
|
||||
{
|
||||
var future = _analytics.CallStatic<AndroidJavaObject>("isEnabled");
|
||||
return new AppCenterTask<bool>(future);
|
||||
}
|
||||
|
||||
public static AndroidJavaObject GetTransmissionTarget(string transmissionTargetToken, out bool success)
|
||||
{
|
||||
var target = _analytics.CallStatic<AndroidJavaObject>("getTransmissionTarget", transmissionTargetToken);
|
||||
success = target != null;
|
||||
return target;
|
||||
}
|
||||
|
||||
public static void Pause()
|
||||
{
|
||||
_analytics.CallStatic("pause");
|
||||
}
|
||||
|
||||
public static void Resume()
|
||||
{
|
||||
_analytics.CallStatic("resume");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a713100f59727486c9ad45c500332234
|
||||
timeCreated: 1497467718
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,44 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
namespace Microsoft.AppCenter.Unity.Analytics.Internal
|
||||
{
|
||||
class EventPropertiesInternal
|
||||
{
|
||||
public static AndroidJavaObject Create()
|
||||
{
|
||||
return new AndroidJavaObject("com.microsoft.appcenter.analytics.EventProperties");
|
||||
}
|
||||
|
||||
public static void SetString(AndroidJavaObject properties, string key, string val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetNumber(AndroidJavaObject properties, string key, long val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetNumber(AndroidJavaObject properties, string key, double val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetBool(AndroidJavaObject properties, string key, bool val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, val);
|
||||
}
|
||||
|
||||
public static void SetDate(AndroidJavaObject properties, string key, DateTime val)
|
||||
{
|
||||
properties.Call<AndroidJavaObject>("set", key, JavaDateHelper.DateTimeConvert(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 514cee750a1f56f4bab5c663b3a4f557
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,70 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics
|
||||
{
|
||||
public class PropertyConfiguratorInternal
|
||||
{
|
||||
public static void SetAppName(AndroidJavaObject propertyConfigurator, string appName)
|
||||
{
|
||||
propertyConfigurator.Call("setAppName", appName);
|
||||
}
|
||||
|
||||
public static void SetUserId(AndroidJavaObject propertyConfigurator, string userId)
|
||||
{
|
||||
propertyConfigurator.Call("setUserId", userId);
|
||||
}
|
||||
|
||||
public static void SetAppVersion(AndroidJavaObject propertyConfigurator, string appVersion)
|
||||
{
|
||||
propertyConfigurator.Call("setAppVersion", appVersion);
|
||||
}
|
||||
|
||||
public static void SetAppLocale(AndroidJavaObject propertyConfigurator, string appLocale)
|
||||
{
|
||||
propertyConfigurator.Call("setAppLocale", appLocale);
|
||||
}
|
||||
|
||||
public static void CollectDeviceId(AndroidJavaObject propertyConfigurator)
|
||||
{
|
||||
propertyConfigurator.Call("collectDeviceId");
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, string value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, DateTime value)
|
||||
{
|
||||
var javaDate = JavaDateHelper.DateTimeConvert(value);
|
||||
propertyConfigurator.Call("setEventProperty", key, javaDate);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, long value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, double value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void SetEventProperty(AndroidJavaObject propertyConfigurator, string key, bool value)
|
||||
{
|
||||
propertyConfigurator.Call("setEventProperty", key, value);
|
||||
}
|
||||
|
||||
public static void RemoveEventProperty(AndroidJavaObject propertyConfigurator, string key)
|
||||
{
|
||||
propertyConfigurator.Call("removeEventProperty", key);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e670e8c4e24f54cb3b15b96cba63313b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,82 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using Microsoft.AppCenter.Unity.Analytics.Internal;
|
||||
using Microsoft.AppCenter.Unity.Internal.Utility;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics
|
||||
{
|
||||
public class TransmissionTargetInternal
|
||||
{
|
||||
public static void TrackEvent(AndroidJavaObject transmissionTarget, string eventName)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName);
|
||||
}
|
||||
|
||||
public static void TrackEvent(AndroidJavaObject transmissionTarget, string eventName, int flags)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName, null, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, IDictionary<string, string> properties)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
transmissionTarget.Call("trackEvent", eventName, androidProperties);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, EventProperties properties)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName, properties.GetRawObject());
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, IDictionary<string, string> properties, int flags)
|
||||
{
|
||||
var androidProperties = JavaStringMapHelper.ConvertToJava(properties);
|
||||
transmissionTarget.Call("trackEvent", eventName, androidProperties, flags);
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(AndroidJavaObject transmissionTarget, string eventName, EventProperties properties, int flags)
|
||||
{
|
||||
transmissionTarget.Call("trackEvent", eventName, properties.GetRawObject(), flags);
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(AndroidJavaObject transmissionTarget, bool enabled)
|
||||
{
|
||||
var future = transmissionTarget.Call<AndroidJavaObject>("setEnabledAsync", enabled);
|
||||
return new AppCenterTask(future);
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
var future = transmissionTarget.Call<AndroidJavaObject>("isEnabledAsync");
|
||||
return new AppCenterTask<bool>(future);
|
||||
}
|
||||
|
||||
public static AndroidJavaObject GetTransmissionTarget(AndroidJavaObject transmissionTargetParent, string transmissionTargetToken, out bool success)
|
||||
{
|
||||
var target = transmissionTargetParent.Call<AndroidJavaObject>("getTransmissionTarget", transmissionTargetToken);
|
||||
success = target != null;
|
||||
return target;
|
||||
}
|
||||
|
||||
public static AndroidJavaObject GetPropertyConfigurator(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
return transmissionTarget.Call<AndroidJavaObject>("getPropertyConfigurator");
|
||||
}
|
||||
|
||||
public static void Pause(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
transmissionTarget.Call("pause");
|
||||
}
|
||||
|
||||
public static void Resume(AndroidJavaObject transmissionTarget)
|
||||
{
|
||||
transmissionTarget.Call("resume");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b4de3e63b6764e059567a9e87feda60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05baa696b2306473096af3c82bf25429
|
||||
folderAsset: yes
|
||||
timeCreated: 1498059884
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,83 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if (!UNITY_IOS && !UNITY_ANDROID && !UNITY_WSA_10_0) || UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics.Internal
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
using RawType = System.IntPtr;
|
||||
#else
|
||||
using RawType = System.Type;
|
||||
#endif
|
||||
|
||||
#if UNITY_IOS
|
||||
using TransmissionTargetType = System.IntPtr;
|
||||
#elif UNITY_ANDROID
|
||||
using TransmissionTargetType = UnityEngine.AndroidJavaObject;
|
||||
#else
|
||||
using TransmissionTargetType = System.Object;
|
||||
#endif
|
||||
|
||||
class AnalyticsInternal
|
||||
{
|
||||
public static void PrepareEventHandlers()
|
||||
{
|
||||
}
|
||||
|
||||
public static void AddNativeType(List<RawType> nativeTypes)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TrackEvent(string eventName)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TrackEvent(string eventName, int flags)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, IDictionary<string, string> properties)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, EventProperties properties)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, IDictionary<string, string> properties, int flags)
|
||||
{
|
||||
}
|
||||
|
||||
public static void TrackEventWithProperties(string eventName, EventProperties properties, int flags)
|
||||
{
|
||||
}
|
||||
|
||||
public static AppCenterTask SetEnabledAsync(bool enabled)
|
||||
{
|
||||
return AppCenterTask.FromCompleted();
|
||||
}
|
||||
|
||||
public static AppCenterTask<bool> IsEnabledAsync()
|
||||
{
|
||||
return AppCenterTask<bool>.FromCompleted(false);
|
||||
}
|
||||
|
||||
public static TransmissionTargetType GetTransmissionTarget(string transmissionTargetToken, out bool success)
|
||||
{
|
||||
success = false;
|
||||
return default(TransmissionTargetType);
|
||||
}
|
||||
|
||||
public static void Pause()
|
||||
{
|
||||
}
|
||||
|
||||
public static void Resume()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 632c05efd92fe4ec9b424381b5392d76
|
||||
timeCreated: 1497465139
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,41 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if (!UNITY_IOS && !UNITY_ANDROID && !UNITY_WSA_10_0) || UNITY_EDITOR
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics.Internal
|
||||
{
|
||||
#if UNITY_IOS
|
||||
using RawType = System.IntPtr;
|
||||
#elif UNITY_ANDROID
|
||||
using RawType = UnityEngine.AndroidJavaObject;
|
||||
#else
|
||||
using RawType = System.Object;
|
||||
#endif
|
||||
|
||||
class EventPropertiesInternal
|
||||
{
|
||||
public static RawType Create()
|
||||
{
|
||||
return default(RawType);
|
||||
}
|
||||
|
||||
public static void SetString(RawType properties, string key, string val)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetNumber(RawType properties, string key, object val)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetBool(RawType properties, string key, bool val)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetDate(RawType properties, string key, DateTime val)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61494a0be6a398041ad0f0aa1de5408e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,66 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#if (!UNITY_IOS && !UNITY_ANDROID && !UNITY_WSA_10_0) || UNITY_EDITOR
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AppCenter.Unity.Analytics.Internal;
|
||||
|
||||
namespace Microsoft.AppCenter.Unity.Analytics
|
||||
{
|
||||
#if UNITY_IOS
|
||||
using RawType = System.IntPtr;
|
||||
#elif UNITY_ANDROID
|
||||
using RawType = UnityEngine.AndroidJavaObject;
|
||||
#else
|
||||
using RawType = System.Object;
|
||||
#endif
|
||||
|
||||
public class PropertyConfiguratorInternal
|
||||
{
|
||||
public static void SetAppName(RawType propertyConfigurator, string appName)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetUserId(RawType propertyConfigurator, string userId)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetAppVersion(RawType propertyConfigurator, string appVersion)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetAppLocale(RawType propertyConfigurator, string appLocale)
|
||||
{
|
||||
}
|
||||
|
||||
public static void CollectDeviceId(RawType propertyConfigurator)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetEventProperty(RawType propertyConfigurator, string key, string value)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetEventProperty(RawType propertyConfigurator, string key, DateTime value)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetEventProperty(RawType propertyConfigurator, string key, long value)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetEventProperty(RawType propertyConfigurator, string key, double value)
|
||||
{
|
||||
}
|
||||
|
||||
public static void SetEventProperty(RawType propertyConfigurator, string key, bool value)
|
||||
{
|
||||
}
|
||||
|
||||
public static void RemoveEventProperty(RawType propertyConfigurator, string key)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user