public UIElementsNotificationSubscriber(VisualElement rootVisualElement) { if (rootVisualElement == null) { throw new ArgumentException(L10n.Tr(k_NullVisualElementExceptionMessage)); } // This notification subscriber needs a specific container to work. // A specific service can create a container with the right class : notification-container var notificationContainer = rootVisualElement.Q(null, k_NotificationContainerClassName); if (notificationContainer == null) { // Since the container does not exist, it is created and inserted as the first element... notificationContainer = new VisualElement(); notificationContainer.AddToClassList(k_NotificationContainerClassName); rootVisualElement.Insert(0, notificationContainer); } notificationContainer.Clear(); var notificationTemplate = EditorGUIUtility.Load(k_NotificationTemplateUxmlPath) as VisualTreeAsset; m_NotificationRoot = notificationTemplate.CloneTree().contentContainer; ServicesUtils.TranslateStringsInTree(m_NotificationRoot); notificationContainer.Add(m_NotificationRoot); rootVisualElement.AddStyleSheetPath(k_NotificationTemplateCommonUssPath); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? k_NotificationTemplateDarkUssPath : k_NotificationTemplateLightUssPath); InitializeNotification(); InitializePager(); }
static void AddStyleSheets(VisualElement styleSheetElement) { styleSheetElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesWindowCommon); styleSheetElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesWindowDark : ServicesUtils.StylesheetPath.servicesWindowLight); styleSheetElement.AddStyleSheetPath(ServicesUtils.StylesheetPath.servicesCommon); styleSheetElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? ServicesUtils.StylesheetPath.servicesDark : ServicesUtils.StylesheetPath.servicesLight); styleSheetElement.AddStyleSheetPath(VisualElementConstants.StyleSheetPaths.PackageInstallation); }
public static void AddStyleSheetPathWithSkinVariant(this VisualElement visualElement, string path) { visualElement.AddStyleSheetPath(path); //if (true) { visualElement.AddStyleSheetPath(path + "Dark"); } /*else * { * visualElement.AddStyleSheetPath(path + "Light"); * }*/ }
internal static void AddDefaultEditorStyleSheets(VisualElement p) { if (p.styleSheets == null) { p.AddStyleSheetPath(s_DefaultCommonStyleSheetPath); if (EditorGUIUtility.isProSkin) { p.AddStyleSheetPath(s_DefaultCommonDarkStyleSheetPath); } else { p.AddStyleSheetPath(s_DefaultCommonLightStyleSheetPath); } } }
public override VisualElement InstantiateControl() { VisualElement element = new VisualElement(); element.AddToClassList("Container"); element.AddStyleSheetPath("Styles/Controls/TypeControl"); var icon = new VisualElement(); icon.AddToClassList("warrning-field"); var typeObject = string.IsNullOrEmpty(base.value) ? null : Type.GetType(base.value); icon.EnableInClassList("valid", typeObject != null); var textField = new TextField(); textField.value = typeObject != null ? typeObject.FullName : ""; textField.OnValueChanged(e => { var type = Type.GetType(e.newValue); base.SetValue(e.newValue); icon.EnableInClassList("valid", type != null); owner.Dirty(ModificationScope.Node); }); element.Add(icon); element.Add(textField); return(element); }
void InitializeRootView() { rootView = this.GetRootVisualContainer(); rootView.name = "graphRootView"; rootView.AddStyleSheetPath("GraphProcessorStyles/BaseGraphView"); }
private void AddStyleSheetPath(VisualElement root, string path) { #if UNITY_2019_1_OR_NEWER root.styleSheets.Add(EditorGUIUtility.Load(path) as StyleSheet); #else root.AddStyleSheetPath(path); #endif }
private PackageManagerUserSettingsProvider(string path, IEnumerable <string> keywords = null) : base(path, SettingsScope.User, keywords) { activateHandler = (text, element) => { ResolveDependencies(); // Create a child to make sure all the style sheets are not added to the root. m_RootVisualElement = new ScrollView(); m_RootVisualElement.StretchToParentSize(); m_RootVisualElement.AddStyleSheetPath(k_UserSettingsStylesheet); m_RootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? k_DarkStylesheet : k_LightStylesheet); m_RootVisualElement.AddStyleSheetPath(k_CommonStylesheet); m_RootVisualElement.styleSheets.Add(m_ResourceLoader.packageManagerCommonStyleSheet); element.Add(m_RootVisualElement); var root = m_ResourceLoader.GetTemplate(k_PackageManagerUserSettingsTemplate); m_RootVisualElement.Add(root); m_Cache = new VisualElementCache(root); DisplayPackagesCacheSetting(); DisplayAssetStoreCachePathSetting(); EditorApplication.focusChanged += OnEditorApplicationFocusChanged; }; deactivateHandler = () => { EditorApplication.focusChanged -= OnEditorApplicationFocusChanged; if (m_UpmCacheRootClient != null) { m_UpmCacheRootClient.onGetCacheRootOperationError -= OnPackagesGetCacheRootOperationError; m_UpmCacheRootClient.onGetCacheRootOperationResult -= OnPackagesGetCacheRootOperationResult; m_UpmCacheRootClient.onSetCacheRootOperationError -= OnPackagesSetCacheRootOperationError; m_UpmCacheRootClient.onSetCacheRootOperationResult -= OnPackagesSetCacheRootOperationResult; m_UpmCacheRootClient.onClearCacheRootOperationError -= OnPackagesClearCacheRootOperationError; m_UpmCacheRootClient.onClearCacheRootOperationResult -= OnPackagesClearCacheRootOperationResult; } if (m_AssetStoreCachePathProxy != null) { m_AssetStoreCachePathProxy.onConfigChanged -= RefreshAssetStoreCachePathConfig; } }; }
private void OnEnable() { VisualElement m_Root = this.GetRootVisualContainer(); m_Root.AddStyleSheetPath("mystyles"); m_Root.AddToClassList("rootClass"); BuildWorkspace(m_Root); }
private static void MultiVersionLoadStyleSheet(VisualElement element, string sheetPath) { #if UNITY_2019_1_OR_NEWER var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>(sheetPath); element.styleSheets.Add(styleSheet); #elif UNITY_2018_1_OR_NEWER element.AddStyleSheetPath(sheetPath); #endif }
private void InitializeRootView() { #if UNITY_2019_3_OR_NEWER _rootView = rootVisualElement; _rootView.styleSheets.Add((StyleSheet)Resources.Load("UdonGraphStyle")); #else _rootView = this.GetRootVisualContainer(); _rootView.AddStyleSheetPath("UdonGraphStyle2018"); #endif }
public static void AssignStyleSheetFromAssetToElement(this VisualTreeAsset vta, VisualElementAsset asset, VisualElement element) { if (asset.hasStylesheetPaths) for (int i = 0; i < asset.stylesheetPaths.Count; i++) element.AddStyleSheetPath(asset.stylesheetPaths[i]); if (asset.hasStylesheets) for (int i = 0; i < asset.stylesheets.Count; ++i) if (asset.stylesheets[i] != null) element.styleSheets.Add(asset.stylesheets[i]); }
/// <summary> /// Initializes UI. /// </summary> void InitializeUI() { if (_initialized) { return; } var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset> (TemplatePath); if (!asset) { return; } #if UNITY_2019_1_OR_NEWER gitDetailActoins = asset.CloneTree().Q("detailActions"); gitDetailActoins.styleSheets.Add(EditorGUIUtility.Load(StylePath) as StyleSheet); #else _gitDetailActoins = asset.CloneTree(null).Q("detailActions"); _gitDetailActoins.AddStyleSheetPath(StylePath); #endif // Add callbacks _hostingIcon.clickable.clicked += () => Application.OpenURL(Utils.GetRepoURL(_packageInfo)); _viewDocumentation.clickable.clicked += () => Application.OpenURL(Utils.GetFileURL(_packageInfo, "README.md")); _viewChangelog.clickable.clicked += () => Application.OpenURL(Utils.GetFileURL(_packageInfo, "CHANGELOG.md")); _viewLicense.clickable.clicked += () => Application.OpenURL(Utils.GetFileURL(_packageInfo, "LICENSE.md")); // Move element to documentationContainer _detailControls = parent.parent.Q("detailsControls"); _documentationContainer = parent.parent.Q("documentationContainer"); _originalDetailActions = _documentationContainer.Q("detailActions"); _documentationContainer.Add(_gitDetailActoins); _updateButton = new Button(AddOrUpdatePackage) { name = "update", text = "Up to date" }; _updateButton.AddToClassList("action"); _versionPopup = new Button(PopupVersions) { text = "hoge", style = { marginLeft = -4, marginRight = -3, marginTop = -3, marginBottom = -3, }, }; _versionPopup.AddToClassList("popup"); _versionPopup.AddToClassList("popupField"); _versionPopup.AddToClassList("versions"); _detailControls.Q("updateCombo").Insert(1, _updateButton); _detailControls.Q("updateDropdownContainer").Add(_versionPopup); _initialized = true; }
public AssetDataDisplay() { Element = new VisualElement().WithClass("result"); Element.AddStyleSheetPath("AssetFinder"); _image = new VisualElement().WithClass("asset-preview"); Element.Add(_image); _name = new SingleHighlightText("highlight", "asset-name"); Element.Add(_name.Container); _path = new SingleHighlightText("highlight", "asset-path"); Element.Add(_path.Container); }
void InitializeProjectBindManager(VisualElement rootVisualElement) { m_LastCreateBlockOrganization = L10n.Tr(k_SelectOrganizationText); m_LastReuseBlockOrganization = L10n.Tr(k_SelectOrganizationText); m_LastReuseBlockProject = L10n.Tr(k_SelectProjectText); rootVisualElement.AddStyleSheetPath(k_ProjectBindCommonStyleSheetPath); rootVisualElement.viewDataKey = k_RootDataKey; rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? k_ProjectBindDarkStyleSheetPath : k_ProjectBindLightStyleSheetPath); var projectBindTemplate = EditorGUIUtility.Load(k_ProjectBindTemplatePath) as VisualTreeAsset; rootVisualElement.Add(projectBindTemplate.CloneTree().contentContainer); projectBindContainer = rootVisualElement.Q(k_ProjectBindContainerName); projectBindContainer.viewDataKey = k_BindContainerDataKey; m_CreateProjectIdBlock = projectBindContainer.Q(k_CreateProjectIdBlockName); m_ReuseProjectIdBlock = projectBindContainer.Q(k_ReuseProjectIdBlockName); m_LastCreateBlockOrganization = string.Empty; m_LastReuseBlockOrganization = string.Empty; SetupCreateProjectIdBlock(); SetupReuseProjectIdBlock(); }
void OnEnable() { // Load elements var root = new VisualElement { name = "root-container" }; var visualTreeAsset = (VisualTreeAsset)EditorResources.Load <UnityEngine.Object>("UXML/ShortcutManager/PromptWindow.uxml"); visualTreeAsset.CloneTree(root, null); rootVisualElement.Add(root); // Load styles if (EditorGUIUtility.isProSkin) { root.AddToClassList("isProSkin"); } root.AddStyleSheetPath("StyleSheets/ShortcutManager/PromptWindow.uss"); // Find elements m_HeaderTextElement = root.Q <TextElement>("header"); m_MessageTextElement = root.Q <TextElement>("message"); var labelAndTextField = root.Q <VisualElement>("label-and-text-field"); m_LabelTextElement = labelAndTextField.Q <TextElement>(); m_TextField = labelAndTextField.Q <TextField>(); var buttons = root.Q <VisualElement>("buttons"); m_SubmitButton = root.Q <Button>("submit"); var cancelButton = root.Q <Button>("cancel"); // Set localized text cancelButton.text = L10n.Tr("Cancel"); // Set up event handlers m_TextField.RegisterValueChangedCallback(OnTextFieldValueChanged); m_TextField.RegisterCallback <KeyDownEvent>(OnTextFieldKeyDown); m_SubmitButton.clickable.clicked += Submit; cancelButton.clickable.clicked += Close; // Flip submit and cancel buttons on macOS if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX) { var parent = m_SubmitButton.parent; parent.Remove(m_SubmitButton); parent.Add(m_SubmitButton); } // Mark last button with class buttons.Children().Last().AddToClassList("last"); }
void OnEnable() { #if UNITY_2019_1_OR_NEWER m_Root = rootVisualElement; m_Root.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(Resources.GetStyleSheetPath("AssetTablesWindow"))); #else m_Root = this.GetRootVisualContainer(); m_Root.AddStyleSheetPath(Resources.GetStyleSheetPath("AssetTablesWindow")); #endif var template = Resources.GetTemplate("AssetTablesWindow"); m_Root.Add(template); template.StretchToParentSize(); SetupPanels(); }
public GenericResultItem() { Element = new VisualElement().WithClass("result"); Element.AddStyleSheetPath("GenericFinder"); _image = new VisualElement().WithClass("generic-preview"); Element.Add(_image); _name = new TextHighlighter("highlight", NamePool); _name.Container.AddToClassList("highlight-container"); Element.Add(_name.Container); _path = new TextHighlighter("highlight", PathPool); _path.Container.AddToClassList("highlight-container"); Element.Add(_path.Container); }
private DocumentationPackageManagerUI(VisualTreeAsset asset) { #if UNITY_2019_1_OR_NEWER root = asset.CloneTree(); var resourcesRoot = "packages/com.unity.package-manager-doctools/Editor/Resources/"; string path = EditorGUIUtility.isProSkin ? resourcesRoot + "Styles/Dark.uss" : resourcesRoot + "Styles/Light.uss"; var styleSheet = EditorGUIUtility.Load(path) as StyleSheet; root.styleSheets.Add(styleSheet); #else root = asset.CloneTree(null); root.AddStyleSheetPath(EditorGUIUtility.isProSkin ? "Styles/Dark" : "Styles/Light"); #endif Add(root); if (!Unsupported.IsDeveloperMode()) { Verbose.visible = false; } GenerateButton.clickable.clicked += GenerateDocClick; Verbose.RegisterValueChangedCallback(evt => VerbosityToggle()); VerbosityToggle(); }
public void OnEnable() { var curveX = AnimationCurve.Linear(0, 0, 1, 0); var curveY = AnimationCurve.EaseInOut(0, 0, 1, 1); var curveZ = AnimationCurve.Linear(0, 0, 1, 0); m_root = this.GetRootVisualContainer(); m_root.AddStyleSheetPath("styles"); AddTestControl <IntegerField, int>(new IntegerField(), (v) => v.ToString()); AddTestControl <IntegerField, int>(new IntegerField(), (v) => v.ToString()); AddTestControl <DoubleField, double>(new DoubleField(), (v) => v.ToString()); AddTestControl <DoubleField, double>(new DoubleField(), (v) => v.ToString()); AddTestControl <TextField, string>(new TextField(), (v) => v); AddTestControl <TextField, string>(new TextField() { isPasswordField = true, maskChar = '*' }, (v) => v); AddTestControl <ColorField, Color>(new ColorField(), (v) => v.ToString()); AddTestControl <ColorField, Color>(new ColorField(), (v) => v.ToString()); AddTestControl <ObjectField, Object>(new ObjectField { objectType = typeof(Camera) }, (v) => v.name); AddTestControl <ObjectField, Object>(new ObjectField { objectType = typeof(GameObject) }, (v) => v.name); AddTestControl <CurveField, AnimationCurve>(new CurveField { value = curveX }, (v) => "keys: " + v.keys.Length + " - pre: " + v.preWrapMode + " - post: " + v.postWrapMode); AddTestControl <CurveField, AnimationCurve>(new CurveField { value = curveY }, (v) => "keys: " + v.keys.Length + " - pre: " + v.preWrapMode + " - post: " + v.postWrapMode); AddTestControl <CurveField, AnimationCurve>(new CurveField { value = curveZ }, (v) => "keys: " + v.keys.Length + " - pre: " + v.preWrapMode + " - post: " + v.postWrapMode); }
void SetupLayout() { m_Root = rootVisualElement; m_Root.AddStyleSheetPath(k_UIElementsEditorWindowCreatorStyleSheetPath); var visualTree = EditorGUIUtility.Load(k_UIElementsEditorWindowCreatorUxmlPath) as VisualTreeAsset; VisualElement uxmlLayout = visualTree.Instantiate(); m_Root.Add(uxmlLayout); m_ErrorMessageBox = m_Root.Q("errorMessageBox"); var cSharpTextField = m_Root.Q <TextField>("cSharpTextField"); cSharpTextField.RegisterCallback <ChangeEvent <string> >(OnCSharpValueChanged); var cSharpTextInput = cSharpTextField.Q(TextField.textInputUssName); cSharpTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey); cSharpTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage()); m_Root.Q <Toggle>("cSharpToggle").RegisterValueChangedCallback((evt) => { m_IsCSharpEnable = evt.newValue; if (!m_IsCSharpEnable) { cSharpTextField.value = ""; m_CSharpName = ""; } cSharpTextInput.SetEnabled(m_IsCSharpEnable); }); m_Root.schedule.Execute(() => cSharpTextField.Focus()); var uxmlTextField = m_Root.Q <TextField>("uxmlTextField"); uxmlTextField.RegisterCallback <ChangeEvent <string> >(e => { m_ErrorMessageBox.style.visibility = Visibility.Hidden; m_UxmlName = e.newValue; }); var uxmlTextInput = uxmlTextField.Q(TextField.textInputUssName); uxmlTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey); uxmlTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage()); m_Root.Q <Toggle>("uxmlToggle").RegisterValueChangedCallback((evt) => { m_IsUxmlEnable = evt.newValue; if (!m_IsUxmlEnable) { uxmlTextField.value = ""; m_UxmlName = ""; } uxmlTextInput.SetEnabled(m_IsUxmlEnable); }); var ussTextField = m_Root.Q <TextField>("ussTextField"); ussTextField.RegisterCallback <ChangeEvent <string> >(e => { m_ErrorMessageBox.style.visibility = Visibility.Hidden; m_UssName = e.newValue; }); var ussTextInput = ussTextField.Q(TextField.textInputUssName); ussTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey); ussTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage()); m_Root.Q <Toggle>("ussToggle").RegisterValueChangedCallback((evt) => { m_IsUssEnable = evt.newValue; if (!m_IsUssEnable) { ussTextField.value = ""; m_UssName = ""; } ussTextInput.SetEnabled(m_IsUssEnable); }); m_Root.Q <Button>("confirmButton").clickable.clicked += CreateNewTemplatesFiles; m_ErrorMessageBox.Q <Image>("warningIcon").image = EditorGUIUtility.GetHelpIcon(MessageType.Warning); HideErrorMessage(); }
void SetupLayout() { m_Root = rootVisualElement; m_Root.AddStyleSheetPath(k_UIElementsEditorWindowCreatorStyleSheetPath); var visualTree = EditorGUIUtility.Load(k_UIElementsEditorWindowCreatorUxmlPath) as VisualTreeAsset; VisualElement uxmlLayout = visualTree.Instantiate(); m_Root.Add(uxmlLayout); m_ErrorMessageBox = m_Root.Q("errorMessageBox"); var cSharpTextField = m_Root.Q <TextField>(k_CSharpTextFieldName); cSharpTextField.RegisterCallback <ChangeEvent <string> >(OnCSharpValueChanged); var cSharpTextInput = cSharpTextField.Q(TextField.textInputUssName); cSharpTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey, TrickleDown.TrickleDown); cSharpTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage(), TrickleDown.TrickleDown); m_Root.schedule.Execute(() => cSharpTextField.Focus()); var uxmlTextField = m_Root.Q <TextField>(k_UXMLTextFieldName); uxmlTextField.RegisterCallback <ChangeEvent <string> >(e => { m_ErrorMessageBox.style.visibility = Visibility.Hidden; m_UxmlName = e.newValue; }); var uxmlTextInput = uxmlTextField.Q(TextField.textInputUssName); uxmlTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey, TrickleDown.TrickleDown); uxmlTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage(), TrickleDown.TrickleDown); m_Root.Q <Toggle>(k_UXMLToggleName).RegisterValueChangedCallback((evt) => { m_IsUxmlEnable = evt.newValue; if (!m_IsUxmlEnable) { uxmlTextField.value = ""; m_UxmlName = ""; } uxmlTextInput.SetEnabled(m_IsUxmlEnable); UpdateActionChoices(); }); var ussTextField = m_Root.Q <TextField>(k_USSTextFieldName); ussTextField.RegisterCallback <ChangeEvent <string> >(e => { m_ErrorMessageBox.style.visibility = Visibility.Hidden; m_UssName = e.newValue; }); var ussTextInput = ussTextField.Q(TextField.textInputUssName); ussTextInput.RegisterCallback <KeyDownEvent>(OnReturnKey, TrickleDown.TrickleDown); ussTextInput.RegisterCallback <FocusEvent>(e => HideErrorMessage(), TrickleDown.TrickleDown); m_Root.Q <Toggle>(k_USSToggleName).RegisterValueChangedCallback((evt) => { m_IsUssEnable = evt.newValue; if (!m_IsUssEnable) { ussTextField.value = ""; m_UssName = ""; } ussTextInput.SetEnabled(m_IsUssEnable); }); var actionsDropdown = m_Root.Q <DropdownField>(k_ActionsDropdownName); actionsDropdown.RegisterValueChangedCallback((evt) => { m_ActionSelected = evt.newValue; }); actionsDropdown.value = string.IsNullOrEmpty(m_ActionSelected) ? k_JustCreateFilesOption : m_ActionSelected; UpdateActionChoices(); var pathIcon = m_Root.Q <VisualElement>(k_PathIconName); pathIcon.style.backgroundImage = EditorGUIUtility.LoadIcon("FolderOpened Icon"); var chooseFolderButton = m_Root.Q <Button>(k_ChooseFolderButtonName); chooseFolderButton.clicked += OnChooseFolderClicked; m_Root.Q <Button>("confirmButton").clickable.clicked += CreateNewTemplatesFiles; m_ErrorMessageBox.Q <Image>("warningIcon").image = EditorGUIUtility.GetHelpIcon(MessageType.Warning); HideErrorMessage(); }
void SetupStyleSheets() { m_ConfigurationBlock.AddStyleSheetPath(UIResourceUtils.purchasingCommonUssPath); m_ConfigurationBlock.AddStyleSheetPath(EditorGUIUtility.isProSkin ? UIResourceUtils.purchasingDarkUssPath : UIResourceUtils.purchasingLightUssPath); }
internal static void SetToolbarStyleSheet(VisualElement ve) { ve.AddStyleSheetPath("StyleSheets/ToolbarCommon.uss"); ve.AddStyleSheetPath("StyleSheets/Toolbar" + (EditorGUIUtility.isProSkin ? "Dark" : "Light") + ".uss"); }
internal static void AddStyleSheet(VisualElement rootVisualElement, string ussFileName) { rootVisualElement.AddStyleSheetPath($"StyleSheets/QuickSearch/{ussFileName}"); }
void InitializeCoppaManager(VisualElement rootVisualElement) { rootVisualElement.AddStyleSheetPath(k_CoppaCommonStyleSheetPath); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? k_CoppaDarkStyleSheetPath : k_CoppaLightStyleSheetPath); var coppaTemplate = EditorGUIUtility.Load(k_CoppaTemplatePath) as VisualTreeAsset; rootVisualElement.Add(coppaTemplate.CloneTree().contentContainer); m_CoppaContainer = rootVisualElement.Q(coppaContainerName); var persistContainer = m_CoppaContainer.Q(k_PersistContainerName); var coppaField = BuildPopupField(m_CoppaContainer, k_CoppaFieldName); //Setup dashboard link var learnMoreClickable = new Clickable(() => { Application.OpenURL(k_CoppaLearnMoreUrl); }); m_CoppaContainer.Q(k_CoppaLearnLinkBtnName).AddManipulator(learnMoreClickable); var originalCoppaValue = UnityConnect.instance.GetProjectInfo().COPPA; var coppaChoicesList = new List <String>() { L10n.Tr(k_No), L10n.Tr(k_Yes) }; if (originalCoppaValue == COPPACompliance.COPPAUndefined) { coppaChoicesList.Insert(0, L10n.Tr(k_Undefined)); } coppaField.choices = coppaChoicesList; SetCoppaFieldValue(originalCoppaValue, coppaField); persistContainer.Q <Button>(k_SaveBtnName).clicked += () => { try { ServicesConfiguration.instance.RequestCurrentProjectCoppaApiUrl(projectCoppaApiUrl => { var payload = $"{{\"coppa\":\"{GetCompliancyJsonValueFromFieldValue(coppaField)}\"}}"; var uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(payload)); var currentSaveRequest = new UnityWebRequest(projectCoppaApiUrl, UnityWebRequest.kHttpVerbPUT) { uploadHandler = uploadHandler }; currentSaveRequest.suppressErrorsToConsole = true; currentSaveRequest.SetRequestHeader("AUTHORIZATION", $"Bearer {UnityConnect.instance.GetUserInfo().accessToken}"); currentSaveRequest.SetRequestHeader("Content-Type", "application/json;charset=UTF-8"); var operation = currentSaveRequest.SendWebRequest(); SetEnabledCoppaControls(coppaContainer, false); operation.completed += asyncOperation => { try { if (currentSaveRequest.responseCode == k_HttpStatusNoContent) { try { var newCompliancyValue = GetCompliancyForFieldValue(coppaField); if (!UnityConnect.instance.SetCOPPACompliance(newCompliancyValue)) { EditorAnalytics.SendCoppaComplianceEvent(new CoppaState() { isCompliant = newCompliancyValue == COPPACompliance.COPPACompliant }); SetCoppaFieldValue(originalCoppaValue, coppaField); SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); exceptionCallback?.Invoke(originalCoppaValue, new CoppaComplianceEditorConfigurationException(k_CoppaComplianceEditorConfigurationExceptionMessage)); } else { originalCoppaValue = newCompliancyValue; SetCoppaFieldValue(originalCoppaValue, coppaField); SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); NotificationManager.instance.Publish(Notification.Topic.CoppaCompliance, Notification.Severity.Info, L10n.Tr(CoppaComplianceChangedMessage)); saveButtonCallback?.Invoke(originalCoppaValue); } } catch (Exception ex) { SetCoppaFieldValue(originalCoppaValue, coppaField); SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); exceptionCallback?.Invoke(originalCoppaValue, new CoppaComplianceEditorConfigurationException(k_CoppaComplianceEditorConfigurationExceptionMessage, ex)); } finally { currentSaveRequest.Dispose(); currentSaveRequest = null; } } else { try { SetCoppaFieldValue(originalCoppaValue, coppaField); SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); exceptionCallback?.Invoke(originalCoppaValue, new CoppaComplianceWebConfigurationException(L10n.Tr(k_CoppaUnexpectedSaveRequestBehaviorMessage)) { error = currentSaveRequest.error, method = currentSaveRequest.method, timeout = currentSaveRequest.timeout, url = currentSaveRequest.url, responseHeaders = currentSaveRequest.GetResponseHeaders(), responseCode = currentSaveRequest.responseCode, isHttpError = (currentSaveRequest.result == UnityWebRequest.Result.ProtocolError), isNetworkError = (currentSaveRequest.result == UnityWebRequest.Result.ConnectionError), }); } finally { currentSaveRequest.Dispose(); currentSaveRequest = null; } } } finally { SetEnabledCoppaControls(coppaContainer, true); } }; }); } catch (Exception ex) { SetCoppaFieldValue(originalCoppaValue, coppaField); SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); exceptionCallback?.Invoke(originalCoppaValue, ex); } }; persistContainer.Q <Button>(k_CancelBtnName).clicked += () => { SetCoppaFieldValue(originalCoppaValue, coppaField); SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); cancelButtonCallback?.Invoke(originalCoppaValue); }; persistContainer.style.display = DisplayStyle.None; coppaField.RegisterValueChangedCallback(evt => { SetPersistContainerVisibility(originalCoppaValue, persistContainer, coppaField); }); }
private void InitializeRootView() { _rootView = this.GetRootVisualContainer(); _rootView.AddStyleSheetPath("UdonGraphStyle"); }
/// <summary> /// Initializes UI. /// </summary> void InitializeUI() { if (_initialized) { return; } var asset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset> (TemplatePath); if (!asset) { return; } #if UNITY_2019_1_OR_NEWER _gitDetailActoins = asset.CloneTree().Q("detailActions"); _gitDetailActoins.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet> (StylePath)); #else _gitDetailActoins = asset.CloneTree(null).Q("detailActions"); _gitDetailActoins.AddStyleSheetPath(StylePath); #endif // Add callbacks _hostingIcon.clickable.clicked += () => Application.OpenURL(PackageUtils.GetRepoHttpUrl(_packageInfo)); _viewDocumentation.clickable.clicked += () => MarkdownUtils.OpenInBrowser(PackageUtils.GetFilePath(_packageInfo, "README.*")); _viewChangelog.clickable.clicked += () => MarkdownUtils.OpenInBrowser(PackageUtils.GetFilePath(_packageInfo, "CHANGELOG.*")); _viewLicense.clickable.clicked += () => MarkdownUtils.OpenInBrowser(PackageUtils.GetFilePath(_packageInfo, "LICENSE.*")); // Move element to documentationContainer _detailControls = parent.parent.Q("detailsControls") ?? parent.parent.parent.parent.Q("packageToolBar"); _documentationContainer = parent.parent.Q("documentationContainer"); _originalDetailActions = _documentationContainer.Q("detailActions"); _documentationContainer.Add(_gitDetailActoins); _updateButton = new Button(AddOrUpdatePackage) { name = "update", text = "Up to date" }; _updateButton.AddToClassList("action"); _versionPopup = new Button(PopupVersions); _versionPopup.AddToClassList("popup"); _versionPopup.AddToClassList("popupField"); _versionPopup.AddToClassList("versions"); if (_detailControls.name == "packageToolBar") { _hostingIcon.style.borderLeftWidth = 0; _hostingIcon.style.borderRightWidth = 0; _versionPopup.style.marginLeft = -10; _detailControls.Q("rightItems").Insert(1, _updateButton); _detailControls.Q("rightItems").Insert(2, _versionPopup); } else { _versionPopup.style.marginLeft = -4; _versionPopup.style.marginRight = -3; _versionPopup.style.marginTop = -3; _versionPopup.style.marginBottom = -3; _detailControls.Q("updateCombo").Insert(1, _updateButton); _detailControls.Q("updateDropdownContainer").Add(_versionPopup); } // Add package button var _root = UIUtils.GetRoot(_gitDetailActoins); _originalAddButton = _root.Q("toolbarAddButton") ?? _root.Q("moreAddOptionsButton"); _addButton = new Button(AddPackage) { name = "moreAddOptionsButton", text = "+" }; _addButton.AddToClassList("toolbarButton"); _addButton.AddToClassList("space"); _addButton.AddToClassList("pulldown"); _originalAddButton.parent.Insert(_originalAddButton.parent.IndexOf(_originalAddButton) + 1, _addButton); _initialized = true; }
public void Initialize(EditorWindow debuggerWindow, VisualElement root) { rootVisualElement = root; VisualTreeAsset template = EditorGUIUtility.Load("UXML/UIElementsDebugger/UIElementsEventsDebugger.uxml") as VisualTreeAsset; template.CloneTree(rootVisualElement); var toolbar = rootVisualElement.MandatoryQ("toolbar"); m_Toolbar = toolbar; base.Initialize(debuggerWindow); rootVisualElement.AddStyleSheetPath("StyleSheets/UIElementsDebugger/UIElementsEventsDebugger.uss"); var eventsDebugger = rootVisualElement.MandatoryQ("eventsDebugger"); eventsDebugger.StretchToParentSize(); m_EventCallbacksScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventCallbacksScrollView"); m_EventTypeFilter = toolbar.MandatoryQ <EventTypeSelectField>("filter-event-type"); m_EventTypeFilter.RegisterCallback <ChangeEvent <ulong> >(OnFilterChange); var refreshButton = toolbar.MandatoryQ <Button>("refresh"); refreshButton.clickable.clicked += Refresh; var clearLogsButton = toolbar.MandatoryQ <Button>("clear-logs"); clearLogsButton.clickable.clicked += () => { ClearLogs(); }; m_ReplaySelectedEventsButton = toolbar.MandatoryQ <Button>("replay-selected-events"); m_ReplaySelectedEventsButton.clickable.clicked += ReplaySelectedEvents; UpdateReplaySelectedEventsButton(); var infoContainer = rootVisualElement.MandatoryQ("eventInfoContainer"); m_LogCountLabel = infoContainer.MandatoryQ <Label>("log-count"); m_SelectionCountLabel = infoContainer.MandatoryQ <Label>("selection-count"); var autoScrollToggle = infoContainer.MandatoryQ <Toggle>("autoscroll"); autoScrollToggle.value = m_AutoScroll; autoScrollToggle.RegisterValueChangedCallback((e) => { m_AutoScroll = e.newValue; }); m_EventPropagationPaths = (Label)rootVisualElement.MandatoryQ("eventPropagationPaths"); m_EventbaseInfo = (Label)rootVisualElement.MandatoryQ("eventbaseInfo"); m_EventsLog = (ListView)rootVisualElement.MandatoryQ("eventsLog"); m_EventsLog.focusable = true; m_EventsLog.selectionType = SelectionType.Multiple; m_EventsLog.onSelectionChange += OnEventsLogSelectionChanged; m_HistogramTitle = (Label)rootVisualElement.MandatoryQ("eventsHistogramTitle"); m_Log = new EventLog(); m_ModificationCount = 0; m_AutoScroll = true; var eventCallbacksScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventCallbacksScrollView"); eventCallbacksScrollView.StretchToParentSize(); var eventPropagationPathsScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventPropagationPathsScrollView"); eventPropagationPathsScrollView.StretchToParentSize(); var eventbaseInfoScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventbaseInfoScrollView"); eventbaseInfoScrollView.StretchToParentSize(); m_EventRegistrationsScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventsRegistrationsScrollView"); DisplayEvents(m_EventRegistrationsScrollView); m_EventRegistrationsScrollView.StretchToParentSize(); m_EventsHistogramScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventsHistogramScrollView"); DisplayHistogram(m_EventsHistogramScrollView); m_EventsHistogramScrollView.StretchToParentSize(); m_EventTimelineScrollView = (ScrollView)rootVisualElement.MandatoryQ("eventTimelineScrollView"); DisplayTimeline(m_EventTimelineScrollView); m_EventTimelineScrollView.SetScrollViewMode(ScrollViewMode.Horizontal); m_EventTimelineScrollView.StretchToParentSize(); m_TimelineLegend = (Label)rootVisualElement.MandatoryQ("eventTimelineTitleLegend"); m_TimelineLegend.RegisterCallback <MouseEnterEvent>(ShowLegend); m_TimelineLegend.RegisterCallback <MouseLeaveEvent>(HideLegend); CreateLegendContainer(); BuildEventsLog(); GlobalCallbackRegistry.IsEventDebuggerConnected = true; }
public PackageManagerProjectSettingsProvider(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, keywords) { activateHandler = (s, element) => { ResolveDependencies(); // Create a child to make sure all the style sheets are not added to the root. rootVisualElement = new ScrollView(); rootVisualElement.StretchToParentSize(); rootVisualElement.AddStyleSheetPath(StylesheetPath.scopedRegistriesSettings); rootVisualElement.AddStyleSheetPath(StylesheetPath.projectSettings); rootVisualElement.AddStyleSheetPath(EditorGUIUtility.isProSkin ? StylesheetPath.stylesheetDark : StylesheetPath.stylesheetLight); rootVisualElement.AddStyleSheetPath(StylesheetPath.stylesheetCommon); rootVisualElement.styleSheets.Add(m_ResourceLoader.packageManagerCommonStyleSheet); element.Add(rootVisualElement); m_GeneralTemplate = EditorGUIUtility.Load(k_GeneralServicesTemplatePath) as VisualTreeAsset; VisualElement newVisualElement = new VisualElement(); m_GeneralTemplate.CloneTree(newVisualElement); rootVisualElement.Add(newVisualElement); cache = new VisualElementCache(rootVisualElement); advancedSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.advancedSettingsExpanded); m_SettingsProxy.onAdvancedSettingsFoldoutChanged += OnAdvancedSettingsFoldoutChanged; advancedSettingsFoldout.RegisterValueChangedCallback(changeEvent => { if (changeEvent.target == advancedSettingsFoldout) { m_SettingsProxy.advancedSettingsExpanded = changeEvent.newValue; } }); scopedRegistriesSettingsFoldout.SetValueWithoutNotify(m_SettingsProxy.scopedRegistriesSettingsExpanded); m_SettingsProxy.onScopedRegistriesSettingsFoldoutChanged += OnScopedRegistriesSettingsFoldoutChanged; scopedRegistriesSettingsFoldout.RegisterValueChangedCallback(changeEvent => { if (changeEvent.target == scopedRegistriesSettingsFoldout) { m_SettingsProxy.scopedRegistriesSettingsExpanded = changeEvent.newValue; } }); preReleaseInfoBox.Q <Button>().clickable.clicked += () => { m_ApplicationProxy.OpenURL($"https://docs.unity3d.com/{m_ApplicationProxy.shortUnityVersion}/Documentation/Manual/pack-preview.html"); }; enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages); enablePreReleasePackages.RegisterValueChangedCallback(changeEvent => { var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.enablePreReleasePackages) { var saveIt = true; if (newValue && !m_SettingsProxy.oneTimeWarningShown) { if (m_ApplicationProxy.DisplayDialog("showPreReleasePackages", L10n.Tr("Show pre-release packages"), k_Message, L10n.Tr("I understand"), L10n.Tr("Cancel"))) { m_SettingsProxy.oneTimeWarningShown = true; } else { saveIt = false; } } if (saveIt) { m_SettingsProxy.enablePreReleasePackages = newValue; m_SettingsProxy.Save(); PackageManagerWindowAnalytics.SendEvent("togglePreReleasePackages"); } } enablePreReleasePackages.SetValueWithoutNotify(m_SettingsProxy.enablePreReleasePackages); }); UIUtils.SetElementDisplay(seeAllPackageVersions, Unsupported.IsDeveloperBuild()); seeAllPackageVersions.SetValueWithoutNotify(m_SettingsProxy.seeAllPackageVersions); seeAllPackageVersions.RegisterValueChangedCallback(changeEvent => { seeAllPackageVersions.SetValueWithoutNotify(changeEvent.newValue); var newValue = changeEvent.newValue; if (newValue != m_SettingsProxy.seeAllPackageVersions) { m_SettingsProxy.seeAllPackageVersions = newValue; m_SettingsProxy.Save(); } }); }; }