public static void UpdateRpcList() { List <string> additionalRpcs = new List <string>(); HashSet <string> currentRpcs = new HashSet <string>(); var types = GetAllSubTypesInScripts(typeof(MonoBehaviour)); int countOldRpcs = 0; foreach (var mono in types) { MethodInfo[] methods = mono.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (MethodInfo method in methods) { bool isOldRpc = false; #pragma warning disable 618 // we let the Editor check for outdated RPC attributes in code. that should not cause a compile warning if (method.IsDefined(typeof(RPC), false)) { countOldRpcs++; isOldRpc = true; } #pragma warning restore 618 if (isOldRpc || method.IsDefined(typeof(PunRPC), false)) { currentRpcs.Add(method.Name); if (!additionalRpcs.Contains(method.Name) && !PhotonNetwork.PhotonServerSettings.RpcList.Contains(method.Name)) { additionalRpcs.Add(method.Name); } } } } if (additionalRpcs.Count > 0) { // LIMITS RPC COUNT if (additionalRpcs.Count + PhotonNetwork.PhotonServerSettings.RpcList.Count >= byte.MaxValue) { if (currentRpcs.Count <= byte.MaxValue) { bool clearList = EditorUtility.DisplayDialog(CurrentLang.IncorrectRPCListTitle, CurrentLang.IncorrectRPCListLabel, CurrentLang.RemoveOutdatedRPCsLabel, CurrentLang.CancelButton); if (clearList) { PhotonNetwork.PhotonServerSettings.RpcList.Clear(); PhotonNetwork.PhotonServerSettings.RpcList.AddRange(currentRpcs); } else { return; } } else { EditorUtility.DisplayDialog(CurrentLang.FullRPCListTitle, CurrentLang.FullRPCListLabel, CurrentLang.SkipRPCListUpdateLabel); return; } } additionalRpcs.Sort(); Undo.RecordObject(PhotonNetwork.PhotonServerSettings, "Update PUN RPC-list"); PhotonNetwork.PhotonServerSettings.RpcList.AddRange(additionalRpcs); PhotonEditor.SaveSettings(); } if (countOldRpcs > 0) { bool convertRPCs = EditorUtility.DisplayDialog(CurrentLang.RpcFoundDialogTitle, CurrentLang.RpcFoundMessage, CurrentLang.RpcReplaceButton, CurrentLang.RpcSkipReplace); if (convertRPCs) { PhotonConverter.ConvertRpcAttribute(""); } } }
void OnGUI() { scrollPos = GUILayout.BeginScrollView(scrollPos); if (guiState == GUIState.Main) { // converter GUILayout.BeginHorizontal(); GUILayout.Label("Settings", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Setup", "Setup wizard for setting up your own server or the cloud."))) { OpenSetup(); } GUILayout.EndHorizontal(); GUILayout.Space(12); // converter GUILayout.BeginHorizontal(); GUILayout.Label("Converter", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Start", "Converts pure Unity Networking to Photon Unity Networking."))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); GUILayout.Space(12); // add PhotonView GUILayout.BeginHorizontal(); GUILayout.Label("Component", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Add PhotonView", "Also in menu: Component, Miscellaneous"))) { if (Selection.activeGameObject != null) { Selection.activeGameObject.AddComponent <PhotonView>(); } } GUILayout.EndHorizontal(); GUILayout.Space(22); // license GUILayout.BeginHorizontal(); GUILayout.Label("Licenses", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Download Free", "Get your free license for up to 100 concurrent players."))) { EditorUtility.OpenWithDefaultApp(UrlFreeLicense); } GUILayout.EndHorizontal(); GUILayout.Space(12); // documentation GUILayout.BeginHorizontal(); GUILayout.Label("Documentation", EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent("Open PDF", "Opens the local documentation pdf."))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent("Open DevNet", "Online documentation for Photon."))) { EditorUtility.OpenWithDefaultApp(UrlDevNet); } if (GUILayout.Button(new GUIContent("Open Forum", "Online support for Photon."))) { EditorUtility.OpenWithDefaultApp(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } else { SetupGUI(); } GUILayout.EndScrollView(); }
protected virtual void UiMainWizard() { GUILayout.Space(15); // title UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage); // wizard info text GUILayout.Label(CurrentLang.WizardMainWindowInfo); GUILayout.Space(15); // pun+ info if (isPunPlus) { GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel); GUILayout.Space(15); } #if !(UNITY_5_0 || UNITY_5) else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iPhone)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); GUILayout.Space(15); } #endif // settings button GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel))) { HighlightSettings(); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip))) { Application.OpenURL(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId)); } if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel))) { this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(15); // converter GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // documentation GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip))) { Application.OpenURL(UrlDevNet); } GUI.skin.label.wordWrap = true; GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel); if (GUILayout.Button(CurrentLang.ComparisonPageButton)) { Application.OpenURL(UrlCompare); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip))) { Application.OpenURL(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
protected virtual void OnGuiMainWizard() { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(WizardIcon); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label(CurrentLang.PUNWizardLabel, EditorStyles.boldLabel); if (isPunPlus) { GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel); } else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS)) { GUILayout.Label(CurrentLang.MobileExportNoteLabel); } EditorGUILayout.Separator(); // settings button GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel))) { this.InitPhotonSetupWindow(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // find / select settings asset GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.SettingsFileLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel))) { EditorGUIUtility.PingObject(PhotonEditor.Current); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); // converter GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // documentation GUILayout.BeginHorizontal(); GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip))) { EditorUtility.OpenWithDefaultApp(UrlDevNet); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip))) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress)); } if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip))) { EditorUtility.OpenWithDefaultApp(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
protected virtual void OnGuiMainWizard() { // settings button GUILayout.BeginHorizontal(); GUILayout.Label("Settings", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Setup", "Setup wizard for setting up your own server or the cloud."))) { this.InitPhotonSetupWindow(); } GUILayout.EndHorizontal(); GUILayout.Space(12); // converter GUILayout.BeginHorizontal(); GUILayout.Label("Converter", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Start", "Converts pure Unity Networking to Photon Unity Networking."))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); GUILayout.Space(12); // add PhotonView GUILayout.BeginHorizontal(); GUILayout.Label("Component", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Add PhotonView", "Also in menu: Component, Miscellaneous"))) { if (Selection.activeGameObject != null) { Selection.activeGameObject.AddComponent <PhotonView>(); } } GUILayout.EndHorizontal(); GUILayout.Space(22); // license GUILayout.BeginHorizontal(); GUILayout.Label("Licenses", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Download Free", "Get your free license for up to 100 concurrent players."))) { EditorUtility.OpenWithDefaultApp(UrlFreeLicense); } GUILayout.EndHorizontal(); GUILayout.Space(12); // documentation GUILayout.BeginHorizontal(); GUILayout.Label("Documentation", EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent("Open PDF", "Opens the local documentation pdf."))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent("Open DevNet", "Online documentation for Photon."))) { EditorUtility.OpenWithDefaultApp(UrlDevNet); } if (GUILayout.Button(new GUIContent("Open Cloud Dashboard", "Review Cloud App information and statistics."))) { EditorUtility.OpenWithDefaultApp(UrlAccountPage + Uri.EscapeUriString(this.emailAddress)); } if (GUILayout.Button(new GUIContent("Open Forum", "Online support for Photon."))) { EditorUtility.OpenWithDefaultApp(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
protected virtual void OnGuiMainWizard() { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(WizardIcon); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUILayout.Separator(); GUILayout.Label("Photon Unity Networking (PUN) Wizard", EditorStyles.boldLabel); if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iPhone)) { GUILayout.Label("Note: Export to mobile will require iOS Pro / Android Pro."); } EditorGUILayout.Separator(); // settings button GUILayout.BeginHorizontal(); GUILayout.Label("Settings", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Setup", "Setup wizard for setting up your own server or the cloud."))) { this.InitPhotonSetupWindow(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // converter GUILayout.BeginHorizontal(); GUILayout.Label("Converter", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Start", "Converts pure Unity Networking to Photon Unity Networking."))) { PhotonConverter.RunConversion(); } GUILayout.EndHorizontal(); EditorGUILayout.Separator(); // find / select settings asset GUILayout.BeginHorizontal(); GUILayout.Label("Settings File", EditorStyles.boldLabel, GUILayout.Width(100)); if (GUILayout.Button(new GUIContent("Locate settings asset", "Highlights the used photon settings file in the project."))) { EditorGUIUtility.PingObject(PhotonEditor.Current); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); // documentation GUILayout.BeginHorizontal(); GUILayout.Label("Documentation", EditorStyles.boldLabel, GUILayout.Width(100)); GUILayout.BeginVertical(); if (GUILayout.Button(new GUIContent("Open PDF", "Opens the local documentation pdf."))) { EditorUtility.OpenWithDefaultApp(DocumentationLocation); } if (GUILayout.Button(new GUIContent("Open DevNet", "Online documentation for Photon."))) { EditorUtility.OpenWithDefaultApp(UrlDevNet); } if (GUILayout.Button(new GUIContent("Open Cloud Dashboard", "Review Cloud App information and statistics."))) { EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress)); } if (GUILayout.Button(new GUIContent("Open Forum", "Online support for Photon."))) { EditorUtility.OpenWithDefaultApp(UrlForum); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public static void UpdateRpcList() { List <string> additionalRpcs = new List <string>(); HashSet <string> currentRpcs = new HashSet <string>(); var types = GetAllSubTypesInScripts(typeof(MonoBehaviour)); int countOldRpcs = 0; foreach (var mono in types) { MethodInfo[] methods = mono.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (MethodInfo method in methods) { bool isOldRpc = false; #pragma warning disable 618 // we let the Editor check for outdated RPC attributes in code. that should not cause a compile warning if (method.IsDefined(typeof(RPC), false)) { countOldRpcs++; isOldRpc = true; } #pragma warning restore 618 if (isOldRpc || method.IsDefined(typeof(PunRPC), false)) { currentRpcs.Add(method.Name); if (!additionalRpcs.Contains(method.Name) && !PhotonNetwork.PhotonServerSettings.RpcList.Contains(method.Name)) { additionalRpcs.Add(method.Name); } } } } if (additionalRpcs.Count > 0) { // LIMITS RPC COUNT if (additionalRpcs.Count + PhotonNetwork.PhotonServerSettings.RpcList.Count >= byte.MaxValue) { if (currentRpcs.Count <= byte.MaxValue) { bool clearList = EditorUtility.DisplayDialog(CurrentLang.IncorrectRPCListTitle, CurrentLang.IncorrectRPCListLabel, CurrentLang.RemoveOutdatedRPCsLabel, CurrentLang.CancelButton); if (clearList) { PhotonNetwork.PhotonServerSettings.RpcList.Clear(); PhotonNetwork.PhotonServerSettings.RpcList.AddRange(currentRpcs); } else { return; } } else { EditorUtility.DisplayDialog(CurrentLang.FullRPCListTitle, CurrentLang.FullRPCListLabel, CurrentLang.SkipRPCListUpdateLabel); return; } } additionalRpcs.Sort(); PhotonNetwork.PhotonServerSettings.RpcList.AddRange(additionalRpcs); EditorUtility.SetDirty(PhotonNetwork.PhotonServerSettings); } if (countOldRpcs > 0) { bool convertRPCs = EditorUtility.DisplayDialog("RPC Attribute Outdated", "Some code uses the obsolete RPC attribute. PUN now requires the PunRPC attribute to mark remote-callable methods.\nThe Editor can search and replace that code which will modify your source.", "Replace. I got a backup.", "Not now."); if (convertRPCs) { PhotonConverter.ConvertRpcAttribute(""); } } }