void DrawServiceElement(IHostingService svc, List <IHostingService> svcList) { bool isDirty = false; string newName = EditorGUILayout.DelayedTextField("Service Name", svc.DescriptiveName); if (svcList.Find(s => s.DescriptiveName == newName) == default(IHostingService)) { svc.DescriptiveName = newName; m_ServicesList.Reload(); isDirty = true; } var typeAndId = string.Format("{0} ({1})", svc.GetType().Name, svc.InstanceId.ToString()); EditorGUILayout.LabelField("Service Type (ID)", typeAndId, GUILayout.MinWidth(225f)); // Allow service to provide additional GUI configuration elements svc.OnGUI(); var newIsServiceEnabled = EditorGUILayout.Toggle("Enable", svc.IsHostingServiceRunning); if (newIsServiceEnabled != svc.IsHostingServiceRunning) { if (newIsServiceEnabled) { svc.StartHostingService(); } else { svc.StopHostingService(); } isDirty = true; } EditorGUILayout.Space(); using (new EditorGUI.DisabledScope(!svc.IsHostingServiceRunning)) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Hosting Service Variables"); var manager = m_Settings.HostingServicesManager; if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false))) { manager.RefreshGlobalProfileVariables(); } GUILayout.EndHorizontal(); DrawProfileVarTable(svc); } if (isDirty && m_Settings != null) { m_Settings.SetDirty(AddressableAssetSettings.ModificationEvent.HostingServicesManagerModified, this, false, true); } }
IHostingService GetManagedService(out AddressableAssetSettings settings) { var m = new HostingServicesManager(); settings = AddressableAssetSettings.Create(k_TestConfigFolder, k_TestConfigName, false, false); settings.HostingServicesManager = m; var group = settings.CreateGroup("testGroup", false, false, false, null); group.AddSchema <BundledAssetGroupSchema>(); settings.groups.Add(group); m.Initialize(settings); return(m.AddHostingService(m_Service.GetType(), "test")); }
void DrawServiceElement(IHostingService svc) { EditorGUILayout.BeginHorizontal(); { svc.DescriptiveName = EditorGUILayout.DelayedTextField("Service EventName", svc.DescriptiveName); var newIsServiceEnabled = GUILayout.Toggle(svc.IsHostingServiceRunning, "Enable Service", "Button", GUILayout.MaxWidth(150f)); if (GUILayout.Button("Remove...", GUILayout.MaxWidth(75f))) { if (EditorUtility.DisplayDialog("Remove Service", "Are you sure?", "Ok", "Cancel")) { m_RemovalQueue.Add(svc); } } else if (newIsServiceEnabled != svc.IsHostingServiceRunning) { if (newIsServiceEnabled) { svc.StartHostingService(); } else { svc.StopHostingService(); } } } EditorGUILayout.EndHorizontal(); var typeAndId = string.Format("{0} ({1})", svc.GetType().Name, svc.InstanceId.ToString()); EditorGUILayout.LabelField("Service Type (ID)", typeAndId, GUILayout.MinWidth(225f)); EditorGUILayout.Space(); using (new EditorGUI.DisabledGroupScope(!svc.IsHostingServiceRunning)) { // Allow service to provide additional GUI configuration elements svc.OnGUI(); EditorGUILayout.Space(); DrawProfileVarTable(svc, svc.ProfileVariables); } }