private void OnEnable() { VisualElement root = rootVisualElement; root.styleSheets.Add(Resources.Load <StyleSheet>("Quick_Style")); VisualTreeAsset tree = Resources.Load <VisualTreeAsset>("Quick_Main"); tree.CloneTree(root); UQueryBuilder <Button> buttons = root.Query <Button>(); buttons.ForEach(SetupButton); }
private void OnEnable() { var root = rootVisualElement; _VisualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/2DMoveAndCollide Core/Editor/Resources/QuickToolTemplate.uxml"); _VisualTree.CloneTree(root); StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/2DMoveAndCollide Core/Editor/Resources/QuickToolStyles.uss"); root.styleSheets.Add(styleSheet); UQueryBuilder <VisualElement> builder = root.Query(classes: new string[] { "spawn-button" }); builder.ForEach(AddButtonFunctionality); }
public void OnEnable() { // Each editor window contains a root VisualElement object VisualElement root = rootVisualElement; // Import UXML VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/Resources/Stady2/QuickTool.uxml"); VisualElement labelFromUXML = visualTree.CloneTree(); root.Add(labelFromUXML); // A stylesheet can be added to a VisualElement. // The style will be applied to the VisualElement and all of its children. StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/Resources/Stady2/QuickTool.uss"); root.styleSheets.Add(styleSheet); UQueryBuilder <Image> uQueryBuilder = rootVisualElement.Query <Image>(); uQueryBuilder.ForEach(SetupImage); }
/// <summary> /// initialize the UI controller buttons /// by query them from the root /// </summary> public void InitControllerButtons() { UQueryBuilder <Button> videoPlayerButtons = windowRoot.Query <Button>(); videoPlayerButtons.ForEach(SetupControllerButton); }
public override void OnActivate(string searchContext, VisualElement rootElement) { // This function is called when the user clicks on the MyCustom element in the Settings window. _settings = PvCustomizerSettings.GetOrCreateSettings(); _srlSettings = new SerializedObject(_settings); keywords = GetSearchKeywordsFromSerializedObject(_srlSettings); var tree = Resource.Load <VisualTreeAsset>("UXML/PvCustomizerSettingsProvider_UXML.uxml"); tree.CloneTree(rootElement); #region images rootElement.Q(className: "logo").style.backgroundImage = new StyleBackground(Resource.Load <Texture2D>("Icons/logo.png")); #endregion #region list-view _rulesListQ = rootElement.Query <ListView>().Name("rulesList"); ListView rulesList = _rulesListQ.First(); rulesList.bindItem = (vi, i) => { FolderRuleOptionsPanel optionsPanel = vi.Q <FolderRuleOptionsPanel>(); if (i >= 0 && _settings.Rules.Count > i) { optionsPanel.SetEnabled(true); SerializedRule serializedRule = ScriptableObject.CreateInstance <SerializedRule>(); serializedRule.rule = _settings.Rules[i]; optionsPanel.SetCurrentBound(serializedRule, null); } else { optionsPanel.SetEnabled(false); } }; rulesList.makeItem = () => { var child = Resource.Load <VisualTreeAsset>("UXML/FolderRuleOptionsPanel_UXML.uxml").CloneTree(); child.style.paddingTop = 5; child.style.paddingBottom = 5; child.style.borderBottomWidth = 3; child.style.borderBottomColor = Color.black; var optionsPanel = child.Q <FolderRuleOptionsPanel>(); optionsPanel.Q <Button>("btn_Reset")?.RemoveFromHierarchy(); optionsPanel.Q <Button>("btn_Cancel")?.RemoveFromHierarchy(); optionsPanel.Q <Button>("btn_Apply")?.RemoveFromHierarchy(); optionsPanel.Q <Button>("btn_Settings")?.RemoveFromHierarchy(); optionsPanel.Q("tag-holder").RemoveFromHierarchy(); optionsPanel.OnDelete = () => DeleteRule(child); return(child); }; rulesList.style.flexGrow = 1; rulesList.Refresh(); #endregion #region tint example + imgui _tintExampleContainer = rootElement.Q <IMGUIContainer>("tintExample"); _tintExampleContainer.onGUIHandler += DrawTintExample; #endregion rootElement.Bind(_srlSettings); }