app center;增加發送ping的秒

This commit is contained in:
Caiyanpeng committed 2021-11-12 16:21:13 +08:00
1 parent 1bd1ffdb5a
commit d754ff3b15
719 files changed
+34172 -2875

No files matched your search

@@ -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);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2dd8894ba1c74f64eba3405e0e466702
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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();
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8b75da1d7e1a6444bb6ca0bfefc96bca
timeCreated: 1502266489
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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:
Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

@@ -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:
@@ -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
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1c0067cc6476946b180484e48966b142
timeCreated: 1497896393
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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
}
@@ -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:
@@ -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);
}
}
@@ -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:
@@ -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);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a8247f056cc059c4aa3d9b57058f5d64
timeCreated: 1502269651
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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:
@@ -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:
@@ -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());
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bb87d249dd7a048688f34b63e118a7b0
timeCreated: 1502216315
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 119814cc89d1e4652975a06e6df567c6
timeCreated: 1504046963
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c39732e4de5a34bfbbda09c28c8e7f9f
timeCreated: 1503349438
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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]];
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0e8996e972247549b62c85a8d7aa869
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ebeca1d941dd04282895d881deecbc6c
timeCreated: 1504725583
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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);
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a40c6c75c7d49cd4ab84b0d6d68a509f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 428e5cf118c809a40b0fbc4b93d77e60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -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 });
}
}
@@ -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:
@@ -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 });
}
}
@@ -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:
@@ -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:
@@ -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();
}
}
}
@@ -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: