Skip to content
This repository was archived by the owner on Oct 17, 2020. It is now read-only.

Commit 24d9de7

Browse files
https://api.playfab.com/releaseNotes/#181105
2 parents 62fb805 + ab20955 commit 24d9de7

9 files changed

Lines changed: 136 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ Testing.meta
4343
/Source/Assets/Plugins
4444
/Source/Assets/Testing
4545
buildBundleOutput.txt
46+
.vs/
945 Bytes
Binary file not shown.

Source/Assets/PlayFabEditorExtensions/Editor/PlayFabEditor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ private void OnGuiInternal()
136136
case PlayFabEditorMenu.MenuStates.Tools:
137137
PlayFabEditorToolsMenu.DrawToolsPanel();
138138
break;
139+
case PlayFabEditorMenu.MenuStates.Packages:
140+
PlayFabEditorPackages.DrawPackagesMenu();
141+
break;
139142
default:
140143
break;
141144
}

Source/Assets/PlayFabEditorExtensions/Editor/Scripts/Panels/PlayFabEditorMenu.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ internal enum MenuStates
1212
Data = 2,
1313
Help = 3,
1414
Tools = 4,
15-
Logout = 5
15+
Packages = 5,
16+
Logout = 6
1617
}
1718

1819
internal static MenuStates _menuState = MenuStates.Sdks;
@@ -29,6 +30,7 @@ public static void DrawMenu()
2930
var helpButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton");
3031
var logoutButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton");
3132
var toolsButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton");
33+
var packagesButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton");
3234

3335
if (_menuState == MenuStates.Sdks)
3436
sdksButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton_selected");
@@ -40,6 +42,8 @@ public static void DrawMenu()
4042
dataButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton_selected");
4143
if (_menuState == MenuStates.Help)
4244
helpButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton_selected");
45+
if (_menuState == MenuStates.Packages)
46+
packagesButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton_selected");
4347
if (_menuState == MenuStates.Tools)
4448
toolsButtonStyle = PlayFabEditorHelper.uiStyle.GetStyle("textButton_selected");
4549

@@ -60,6 +64,8 @@ public static void DrawMenu()
6064
OnDataClicked();
6165
if (GUILayout.Button("TOOLS", toolsButtonStyle, GUILayout.MaxWidth(45)))
6266
OnToolsClicked();
67+
if(GUILayout.Button("PACKAGES", packagesButtonStyle, GUILayout.MaxWidth(72)))
68+
OnPackagesClicked();
6369
}
6470

6571
if (GUILayout.Button("HELP", helpButtonStyle, GUILayout.MaxWidth(45)))
@@ -106,6 +112,13 @@ public static void OnSettingsClicked()
106112
PlayFabEditorPrefsSO.Instance.curMainMenuIdx = (int)_menuState;
107113
}
108114

115+
public static void OnPackagesClicked()
116+
{
117+
_menuState = MenuStates.Packages;
118+
PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnMenuItemClicked, MenuStates.Packages.ToString());
119+
PlayFabEditorPrefsSO.Instance.curMainMenuIdx = (int)_menuState;
120+
}
121+
109122
public static void OnLogoutClicked()
110123
{
111124
_menuState = MenuStates.Logout;
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
using System;
4+
using System.Reflection;
5+
6+
namespace PlayFab.PfEditor
7+
{
8+
public class PlayFabEditorPackages : Editor
9+
{
10+
private const int buttonWidth = 150;
11+
12+
public static bool IsPubSubPresent { get { return GetIsPubSubTypePresent(); } }
13+
14+
public static void DrawPackagesMenu()
15+
{
16+
#if ENABLE_PLAYFABPUBSUB_API
17+
var labelStyle = new GUIStyle(PlayFabEditorHelper.uiStyle.GetStyle("label"));
18+
if (Environment.Version.Major < 4)
19+
{
20+
EditorGUILayout.LabelField(" PersistentSockets is only supported with dot Net 4\n\n Please change your Project build settings", labelStyle, GUILayout.MinWidth(EditorGUIUtility.currentViewWidth));
21+
}
22+
else if (!IsPubSubPresent)
23+
{
24+
GUILayout.BeginHorizontal();
25+
GUILayout.Label(" PersistentSockets: ");
26+
if (GUILayout.Button("Install", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(buttonWidth), GUILayout.MinHeight(32)))
27+
{
28+
string possibleNewtonsoftPath = "";
29+
if (GetIsNewtonsoftInstalled(out possibleNewtonsoftPath))
30+
{
31+
EditorUtility.DisplayDialog("Newtonsoft is already installed.",
32+
"Please delete your version of Netwonsoft.json.dll in \n\n" + possibleNewtonsoftPath + " \n and retry the install.\n\n Compiler conflicts will occur if this package is installed and Newtonsoft already exists.", "Continue", "Cancel");
33+
}
34+
else
35+
{
36+
ImportPubSubSDK();
37+
}
38+
}
39+
40+
GUILayout.EndHorizontal();
41+
}
42+
else
43+
{
44+
EditorGUILayout.LabelField(" PersistentSockets is Installed", labelStyle, GUILayout.MinWidth(EditorGUIUtility.currentViewWidth));
45+
}
46+
#endif
47+
}
48+
49+
public static void ImportPubSubSDK()
50+
{
51+
var link = "https://api.playfab.com/downloads/unity-signalr";
52+
PlayFabEditorHttp.MakeDownloadCall(link, (fileName) =>
53+
{
54+
AssetDatabase.ImportPackage(fileName, false);
55+
});
56+
}
57+
58+
public static bool GetIsNewtonsoftInstalled(out string path)
59+
{
60+
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
61+
foreach (var assembly in allAssemblies)
62+
{
63+
if (assembly.FullName.Contains("Newtonsoft.Json"))
64+
{
65+
path = assembly.Location;
66+
return true;
67+
}
68+
69+
foreach (var eachType in assembly.GetTypes())
70+
{
71+
if (eachType.Name.Contains("Newtonsoft"))
72+
{
73+
path = assembly.Location;
74+
return true;
75+
}
76+
}
77+
}
78+
path = "N/A";
79+
return false;
80+
}
81+
82+
// TODO: move this function to a shared location
83+
// and CACHE the results so we don't need to loop multiple times.
84+
public static bool GetIsPubSubTypePresent()
85+
{
86+
var allAssemblies = AppDomain.CurrentDomain.GetAssemblies();
87+
88+
foreach (var assembly in allAssemblies)
89+
{
90+
foreach (var eachType in assembly.GetTypes())
91+
{
92+
if (eachType.Name.Contains("PubSub"))
93+
{
94+
return true;
95+
}
96+
}
97+
}
98+
99+
return false;
100+
}
101+
}
102+
}

Source/Assets/PlayFabEditorExtensions/Editor/Scripts/Panels/PlayFabEditorPackages.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.

Source/Assets/PlayFabEditorExtensions/Editor/Scripts/Panels/PlayFabEditorSDKTools.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace PlayFab.PfEditor
99
{
1010
public class PlayFabEditorSDKTools : UnityEditor.Editor
1111
{
12+
private const int buttonWidth = 150;
1213
public static bool IsInstalled { get { return GetPlayFabSettings() != null; } }
1314

1415
private static Type playFabSettingsType = null;
@@ -200,14 +201,13 @@ private static void ShowSdkNotInstalledMenu()
200201

201202
using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")))
202203
{
203-
var buttonWidth = 150;
204-
205204
GUILayout.FlexibleSpace();
206205
if (GUILayout.Button("Refresh", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(buttonWidth), GUILayout.MinHeight(32)))
207206
playFabSettingsType = null;
208207
GUILayout.FlexibleSpace();
209208
if (GUILayout.Button("Install PlayFab SDK", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(buttonWidth), GUILayout.MinHeight(32)))
210209
ImportLatestSDK();
210+
211211
GUILayout.FlexibleSpace();
212212
}
213213
}

Source/Assets/PlayFabEditorExtensions/Editor/Scripts/Utils/PlayFabEditorHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static partial class PlayFabEditorHelper
3333
public static string DEBUG_REQUEST_TIMING = "PLAYFAB_REQUEST_TIMING";
3434
public static string ENABLE_PLAYFABPLAYSTREAM_API = "ENABLE_PLAYFABPLAYSTREAM_API";
3535
public static string ENABLE_BETA_FETURES = "ENABLE_PLAYFAB_BETA";
36+
public static string ENABLE_PLAYFABPUBSUB_API = "ENABLE_PLAYFABPUBSUB_API";
3637
public static Dictionary<string, PfDefineFlag> FLAG_LABELS = new Dictionary<string, PfDefineFlag> {
3738
{ ADMIN_API, new PfDefineFlag { Flag = ADMIN_API, Label = "ENABLE ADMIN API", Category = PfDefineFlag.FlagCategory.Api, isInverted = false, isSafe = true } },
3839
{ CLIENT_API, new PfDefineFlag { Flag = CLIENT_API, Label = "ENABLE CLIENT API", Category = PfDefineFlag.FlagCategory.Api, isInverted = true, isSafe = true } },
@@ -41,7 +42,7 @@ public static partial class PlayFabEditorHelper
4142

4243
{ DEBUG_REQUEST_TIMING, new PfDefineFlag { Flag = DEBUG_REQUEST_TIMING, Label = "ENABLE REQUEST TIMES", Category = PfDefineFlag.FlagCategory.Feature, isInverted = false, isSafe = true } },
4344
{ ENABLE_BETA_FETURES, new PfDefineFlag { Flag = ENABLE_BETA_FETURES, Label = "ENABLE UNSTABLE FEATURES", Category = PfDefineFlag.FlagCategory.Feature, isInverted = false, isSafe = true } },
44-
{ ENABLE_PLAYFABPLAYSTREAM_API, new PfDefineFlag { Flag = ENABLE_PLAYFABPLAYSTREAM_API, Label = "ENABLE SIGNALR", Category = PfDefineFlag.FlagCategory.Feature, isInverted = false, isSafe = false } },
45+
//{ ENABLE_PLAYFABPUBSUB_API, new PfDefineFlag { Flag = ENABLE_PLAYFABPUBSUB_API, Label = "ENABLE PubSub", Category = PfDefineFlag.FlagCategory.Feature, isInverted = false, isSafe = false } },
4546
};
4647

4748
public static string DEFAULT_SDK_LOCATION = "Assets/PlayFabSdk";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
namespace PlayFab.PfEditor { public static partial class PlayFabEditorHelper { public static string EDEX_VERSION = "2.53.181001"; } }
1+
namespace PlayFab.PfEditor { public static partial class PlayFabEditorHelper { public static string EDEX_VERSION = "2.54.181105"; } }

0 commit comments

Comments
 (0)