Skip to content

Commit 352acad

Browse files
authored
Merge pull request #447 from microsoft/fix/sdk-wont-work-without-distribute
UpdateTrack enum removed from AppCenterSettings
2 parents 8892184 + 802584c commit 352acad

File tree

7 files changed

+89
-3
lines changed

7 files changed

+89
-3
lines changed

Assets/AppCenter/AppCenterSettings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Linq;
77
using System.Reflection;
88
using Microsoft.AppCenter.Unity;
9-
using Microsoft.AppCenter.Unity.Distribute;
109
using UnityEngine;
1110

1211
[Serializable]
@@ -48,7 +47,9 @@ public class AppCenterSettings : ScriptableObject
4847

4948
public LogLevel InitialLogLevel = LogLevel.Info;
5049

51-
public UpdateTrack UpdateTrack = UpdateTrack.Public;
50+
[CustomDropDownProperty("Public", 1)]
51+
[CustomDropDownProperty("Private", 2)]
52+
public int UpdateTrack;
5253

5354
public CustomUrlProperty CustomLogUrl = new CustomUrlProperty("Log");
5455

Assets/AppCenter/Editor/AppCenterPreBuild.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private void AddStartupCode(IAppCenterSettingsMaker settingsMaker)
144144
{
145145
settingsMaker.SetDistributeDisableAutomaticCheckForUpdate();
146146
}
147-
settingsMaker.SetUpdateTrack((int)settings.UpdateTrack);
147+
settingsMaker.SetUpdateTrack(settings.UpdateTrack);
148148
settingsMaker.StartDistributeClass();
149149
}
150150
if (advancedSettings != null)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using UnityEditor;
7+
using UnityEngine;
8+
9+
[CustomPropertyDrawer(typeof(CustomDropDownPropertyAttribute))]
10+
public class CustomDropDownPropertyDrawer : PropertyDrawer
11+
{
12+
bool _initialized = false;
13+
object[] _attributes = null;
14+
Dictionary<string, int> _optionsDictionary = new Dictionary<string, int>();
15+
string[] _options = null;
16+
int _selectedIndex = 0;
17+
18+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
19+
{
20+
if (!_initialized)
21+
{
22+
_attributes = fieldInfo.GetCustomAttributes(typeof(CustomDropDownPropertyAttribute), false);
23+
foreach (var itemAttribute in _attributes)
24+
{
25+
var customPropertyAttribute = itemAttribute as CustomDropDownPropertyAttribute;
26+
_optionsDictionary.Add(customPropertyAttribute.SelectedKey, customPropertyAttribute.SelectedValue);
27+
if (customPropertyAttribute.SelectedValue == AppCenterSettingsContext.SettingsInstance.UpdateTrack)
28+
{
29+
_selectedIndex = ArrayUtility.IndexOf(_attributes, itemAttribute);
30+
}
31+
}
32+
_options = _optionsDictionary.Keys.ToArray();
33+
_initialized = true;
34+
}
35+
36+
_selectedIndex = EditorGUI.Popup(position, property.displayName, _selectedIndex, _options);
37+
property.intValue = _optionsDictionary[_options[_selectedIndex]];
38+
}
39+
}

Assets/AppCenter/Editor/CustomDropDownPropertyDrawer.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System;
5+
using UnityEngine;
6+
7+
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
8+
public class CustomDropDownPropertyAttribute : PropertyAttribute
9+
{
10+
public CustomDropDownPropertyAttribute(string key, int value)
11+
{
12+
SelectedKey = key;
13+
SelectedValue = value;
14+
}
15+
16+
public CustomDropDownPropertyAttribute()
17+
{
18+
}
19+
20+
public string SelectedKey { get; private set; }
21+
public int SelectedValue { get; private set; }
22+
}

Assets/AppCenter/Properties/CustomDropDownPropertyAttribute.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### App Center
66

7+
* **[Fix]** Fix SDK doesn't work without `Distribute` package.
8+
79
#### iOS
810

911
* **[Fix]** Add missing system dependencies that aren't implicitly included when `APPCENTER_DONT_USE_NATIVE_STARTER` flag is used.

0 commit comments

Comments
 (0)