app center;增加發送ping的秒
This commit is contained in:
1 parent
1bd1ffdb5a
commit
d754ff3b15
719 files changed
+34172
-2875
No files matched your search
+31
@@ -0,0 +1,31 @@
|
||||
namespace AppCenterEditor
|
||||
{
|
||||
public class AppCenterAnalyticsPackage : AppCenterSDKPackage
|
||||
{
|
||||
private const string AnalyticsLatestDownload = "https://mobilecentersdkdev.blob.core.windows.net/sdk/AppCenterAnalyticsLatest.unitypackage";
|
||||
private const string AnalyticsDownloadFormat = "https://github.com/Microsoft/AppCenter-SDK-Unity/releases/download/{0}/AppCenterAnalytics-v{0}.unitypackage";
|
||||
|
||||
public static AppCenterAnalyticsPackage Instance = new AppCenterAnalyticsPackage();
|
||||
|
||||
public override string Name { get { return "Analytics"; } }
|
||||
|
||||
protected override bool IsSupportedForWSA { get { return true; } }
|
||||
|
||||
public override string TypeName { get { return "Microsoft.AppCenter.Unity.Analytics.Analytics"; } }
|
||||
|
||||
public override string VersionFieldName { get { return "AnalyticsSDKVersion"; } }
|
||||
|
||||
public override string DownloadLatestUrl { get { return AnalyticsLatestDownload; } }
|
||||
|
||||
public override string DownloadUrlFormat { get { return AnalyticsDownloadFormat; } }
|
||||
|
||||
protected override bool IsSdkPackageSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private AppCenterAnalyticsPackage()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 564bbf408bc68c04fa37ddf06c3a47de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
namespace AppCenterEditor
|
||||
{
|
||||
public class AppCenterCrashesPackage : AppCenterSDKPackage
|
||||
{
|
||||
private const string CrashesLatestDownload = "https://mobilecentersdkdev.blob.core.windows.net/sdk/AppCenterCrashesLatest.unitypackage";
|
||||
private const string CrashesDownloadFormat = "https://github.com/Microsoft/AppCenter-SDK-Unity/releases/download/{0}/AppCenterCrashes-v{0}.unitypackage";
|
||||
|
||||
public static AppCenterCrashesPackage Instance = new AppCenterCrashesPackage();
|
||||
|
||||
public override string Name { get { return "Crashes"; } }
|
||||
|
||||
protected override bool IsSupportedForWSA { get { return false; } }
|
||||
|
||||
public override string TypeName { get { return "Microsoft.AppCenter.Unity.Crashes.Crashes"; } }
|
||||
|
||||
public override string VersionFieldName { get { return "CrashesSDKVersion"; } }
|
||||
|
||||
public override string DownloadLatestUrl { get { return CrashesLatestDownload; } }
|
||||
|
||||
public override string DownloadUrlFormat { get { return CrashesDownloadFormat; } }
|
||||
|
||||
protected override bool IsSdkPackageSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private AppCenterCrashesPackage()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2adc8c1aa0190947ae545aac1d99de0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
namespace AppCenterEditor
|
||||
{
|
||||
public class AppCenterDistributePackage : AppCenterSDKPackage
|
||||
{
|
||||
private const string DistributeLatestDownload = "https://mobilecentersdkdev.blob.core.windows.net/sdk/AppCenterDistributeLatest.unitypackage";
|
||||
private const string DistributeDownloadFormat = "https://github.com/Microsoft/AppCenter-SDK-Unity/releases/download/{0}/AppCenterDistribute-v{0}.unitypackage";
|
||||
|
||||
public static AppCenterDistributePackage Instance = new AppCenterDistributePackage();
|
||||
|
||||
public override string TypeName { get { return "Microsoft.AppCenter.Unity.Distribute.Distribute"; } }
|
||||
|
||||
public override string VersionFieldName { get { return "DistributeSDKVersion"; } }
|
||||
|
||||
public override string Name { get { return "Distribute"; } }
|
||||
|
||||
protected override bool IsSupportedForWSA { get { return false; } }
|
||||
|
||||
public override string DownloadLatestUrl { get { return DistributeLatestDownload; } }
|
||||
|
||||
public override string DownloadUrlFormat { get { return DistributeDownloadFormat; } }
|
||||
|
||||
protected override bool IsSdkPackageSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private AppCenterDistributePackage()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4c7d12311fbe6c4dbdc48c7f0c955d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
namespace AppCenterEditor
|
||||
{
|
||||
public abstract class AppCenterSDKPackage
|
||||
{
|
||||
private static int angle = 0;
|
||||
|
||||
public static IEnumerable<AppCenterSDKPackage> SupportedPackages = new AppCenterSDKPackage[]
|
||||
{
|
||||
AppCenterAnalyticsPackage.Instance,
|
||||
AppCenterCrashesPackage.Instance,
|
||||
AppCenterDistributePackage.Instance,
|
||||
};
|
||||
|
||||
public string InstalledVersion { get; private set; }
|
||||
public bool IsInstalled { get; set; }
|
||||
public bool IsPackageInstalling { get; set; }
|
||||
public bool IsObjectFieldActive { get; set; }
|
||||
protected abstract bool IsSupportedForWSA { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string DownloadLatestUrl { get; }
|
||||
public abstract string DownloadUrlFormat { get; }
|
||||
public abstract string TypeName { get; }
|
||||
public abstract string VersionFieldName { get; }
|
||||
protected abstract bool IsSdkPackageSupported();
|
||||
|
||||
public static IEnumerable<AppCenterSDKPackage> GetInstalledPackages()
|
||||
{
|
||||
var installedPackages = new List<AppCenterSDKPackage>();
|
||||
foreach (var package in SupportedPackages)
|
||||
{
|
||||
if (package.IsInstalled)
|
||||
{
|
||||
installedPackages.Add(package);
|
||||
}
|
||||
}
|
||||
return installedPackages;
|
||||
}
|
||||
|
||||
private void RemovePackage(bool prompt = true)
|
||||
{
|
||||
if (prompt && !EditorUtility.DisplayDialog("Confirm SDK Removal", string.Format("This action will remove the current {0} SDK.", Name), "Confirm", "Cancel"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
EdExLogger.LoggerInstance.LogWithTimeStamp(string.Format("Removing {0} package...", Name));
|
||||
|
||||
var toDelete = new List<string>();
|
||||
string pluginsPath = Path.Combine(AppCenterEditorPrefsSO.Instance.SdkPath, "Plugins");
|
||||
string androidPath = Path.Combine(pluginsPath, "Android");
|
||||
string sdkPath = Path.Combine(pluginsPath, "AppCenterSDK");
|
||||
string iosPath = Path.Combine(pluginsPath, "iOS");
|
||||
string wsaPath = Path.Combine(pluginsPath, "WSA");
|
||||
toDelete.Add(Path.Combine(androidPath, string.Format("appcenter-{0}-release.aar", Name.ToLower())));
|
||||
toDelete.AddRange(Directory.GetFiles(Path.Combine(sdkPath, Name)));
|
||||
toDelete.AddRange(Directory.GetDirectories(Path.Combine(sdkPath, Name)));
|
||||
toDelete.Add(Path.Combine(sdkPath, Name));
|
||||
toDelete.AddRange(Directory.GetFiles(Path.Combine(iosPath, Name)));
|
||||
toDelete.AddRange(Directory.GetDirectories(Path.Combine(iosPath, Name)));
|
||||
toDelete.Add(Path.Combine(iosPath, Name));
|
||||
if (IsSupportedForWSA)
|
||||
{
|
||||
toDelete.AddRange(Directory.GetFiles(Path.Combine(wsaPath, Name)));
|
||||
toDelete.AddRange(Directory.GetDirectories(Path.Combine(wsaPath, Name)));
|
||||
toDelete.Add(Path.Combine(wsaPath, Name));
|
||||
}
|
||||
|
||||
bool deleted = true;
|
||||
|
||||
foreach (var path in toDelete)
|
||||
{
|
||||
if (!FileUtil.DeleteFileOrDirectory(path))
|
||||
{
|
||||
if (!path.EndsWith("meta"))
|
||||
{
|
||||
deleted = false;
|
||||
}
|
||||
}
|
||||
FileUtil.DeleteFileOrDirectory(path + ".meta");
|
||||
}
|
||||
|
||||
// Remove Core if no packages left.
|
||||
List<AppCenterSDKPackage> installedPackages = new List<AppCenterSDKPackage>();
|
||||
installedPackages.AddRange(GetInstalledPackages());
|
||||
if (installedPackages.Count <= 1)
|
||||
{
|
||||
AppCenterEditorSDKTools.RemoveSdk(false);
|
||||
}
|
||||
|
||||
if (deleted)
|
||||
{
|
||||
EdExLogger.LoggerInstance.LogWithTimeStamp(string.Format("{0} package removed.", Name));
|
||||
AppCenterEditor.RaiseStateUpdate(AppCenterEditor.EdExStates.OnSuccess, string.Format("App Center {0} SDK removed.", Name));
|
||||
|
||||
// HACK for 5.4, AssetDatabase.Refresh(); seems to cause the install to fail.
|
||||
if (prompt)
|
||||
{
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AppCenterEditor.RaiseStateUpdate(AppCenterEditor.EdExStates.OnError, string.Format("An unknown error occured and the {0} SDK could not be removed.", Name));
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPackageInstalledMenu()
|
||||
{
|
||||
var isPackageSupported = IsSdkPackageSupported();
|
||||
|
||||
using (new AppCenterGuiFieldHelper.UnityVertical(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
var sdkPackageVersion = InstalledVersion;
|
||||
using (new AppCenterGuiFieldHelper.UnityHorizontal(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
var labelStyle = new GUIStyle(AppCenterEditorHelper.uiStyle.GetStyle("versionText"));
|
||||
EditorGUILayout.LabelField(string.Format("{0} SDK {1} is installed", Name, sdkPackageVersion), labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
|
||||
bool packageVersionIsValid = sdkPackageVersion != null && sdkPackageVersion != Constants.UnknownVersion;
|
||||
if (packageVersionIsValid && sdkPackageVersion.CompareTo(AppCenterEditorSDKTools.InstalledSdkVersion) != 0)
|
||||
{
|
||||
using (new AppCenterGuiFieldHelper.UnityHorizontal(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.LabelField("Warning! Package version is not equal to the AppCenter Core SDK version. ", AppCenterEditorHelper.uiStyle.GetStyle("orTxt"));
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
|
||||
if (isPackageSupported && AppCenterEditorSDKTools.SdkFolder != null)
|
||||
{
|
||||
using (new AppCenterGuiFieldHelper.UnityHorizontal(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Remove SDK", AppCenterEditorHelper.uiStyle.GetStyle("textButton")))
|
||||
{
|
||||
RemovePackage();
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPackageNotInstalledMenu()
|
||||
{
|
||||
using (new AppCenterGuiFieldHelper.UnityVertical(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
using (new AppCenterGuiFieldHelper.UnityHorizontal(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
var labelStyle = new GUIStyle(AppCenterEditorHelper.uiStyle.GetStyle("versionText"));
|
||||
EditorGUILayout.LabelField(string.Format("{0} SDK is not installed.", Name), labelStyle);
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
|
||||
using (new AppCenterGuiFieldHelper.UnityHorizontal(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
if (IsPackageInstalling)
|
||||
{
|
||||
var image = DrawUtils.RotateImage(AssetDatabase.LoadAssetAtPath("Assets/AppCenterEditorExtensions/Editor/UI/Images/wheel.png", typeof(Texture2D)) as Texture2D, angle++);
|
||||
GUILayout.Button(new GUIContent(string.Format(" {0} SDK is installing", Name), image), AppCenterEditorHelper.uiStyle.GetStyle("customButton"), GUILayout.MaxWidth(200), GUILayout.MinHeight(32));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUILayout.Button("Install SDK", AppCenterEditorHelper.uiStyle.GetStyle("textButton")))
|
||||
{
|
||||
AppCenterEditorSDKTools.IsInstalling = IsPackageInstalling = true;
|
||||
ImportLatestPackageSDK();
|
||||
}
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDownloadUrl(string version)
|
||||
{
|
||||
if (string.IsNullOrEmpty(version) || version == Constants.UnknownVersion)
|
||||
{
|
||||
return DownloadLatestUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Format(DownloadUrlFormat, version);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetInstalledVersion(Type type, string coreVersion)
|
||||
{
|
||||
foreach (var field in type.GetFields())
|
||||
{
|
||||
if (field.Name == VersionFieldName)
|
||||
{
|
||||
InstalledVersion = field.GetValue(field).ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (string.IsNullOrEmpty(InstalledVersion))
|
||||
{
|
||||
InstalledVersion = Constants.UnknownVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportLatestPackageSDK()
|
||||
{
|
||||
try
|
||||
{
|
||||
PackagesInstaller.ImportLatestSDK(new[] { this }, AppCenterEditorSDKTools.LatestSdkVersion);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
EdExLogger.LoggerInstance.LogError("Failed to import package: " + exception);
|
||||
AppCenterEditorSDKTools.IsInstalling = IsPackageInstalling = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9eea6442f3431d240b5fc226398b147f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user