public BuilderInspectorInheritedStyles(BuilderInspector inspector, BuilderInspectorMatchingSelectors matchingSelectors) { m_Inspector = inspector; m_Selection = inspector.selection; m_PaneWindow = inspector.paneWindow; m_MatchingSelectors = matchingSelectors; m_InheritedStylesSection = m_Inspector.Q <PersistedFoldout>("inspector-inherited-styles-foldout"); m_ClassListContainer = m_Inspector.Q("class-list-container"); m_MatchingSelectorsFoldout = m_Inspector.Q <PersistedFoldout>("matching-selectors-container"); m_AddClassField = m_Inspector.Q <TextField>("add-class-field"); m_AddClassField.isDelayed = true; m_AddClassField.RegisterCallback <KeyUpEvent>(OnAddClassFieldChange); m_AddClassButton = m_Inspector.Q <Button>("add-class-button"); m_CreateClassButton = m_Inspector.Q <Button>("create-class-button"); m_AddClassValidationMessageContainer = m_Inspector.Q("add-class-validation-message-container"); m_AddClassValidationMessageContainer.Add(new IMGUIContainer(DrawAddClassValidationMessage)); m_AddClassValidationMessageContainer.style.display = DisplayStyle.None; m_ClassPillTemplate = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>( BuilderConstants.UIBuilderPackagePath + "/BuilderClassPill.uxml"); m_AddClassButton.clickable.clicked += AddStyleClass; m_CreateClassButton.clickable.clicked += ExtractLocalStylesToNewClass; m_AddClassValidationRegex = new Regex(@"^[a-zA-Z0-9\-_]+$"); }
public BuilderInspectorInheritedStyles(BuilderInspector inspector, BuilderInspectorMatchingSelectors matchingSelectors) { m_Inspector = inspector; m_Selection = inspector.selection; m_PaneWindow = inspector.paneWindow; m_MatchingSelectors = matchingSelectors; m_InheritedStylesSection = m_Inspector.Q <PersistedFoldout>("inspector-inherited-styles-foldout"); m_ClassListContainer = m_Inspector.Q("class-list-container"); m_MatchingSelectorsFoldout = m_Inspector.Q <PersistedFoldout>("matching-selectors-container"); m_AddClassField = m_Inspector.Q <TextField>("add-class-field"); m_AddClassField.isDelayed = true; m_AddClassField.RegisterCallback <KeyUpEvent>(OnAddClassFieldChange); m_AddClassButton = m_Inspector.Q <Button>("add-class-button"); m_CreateClassButton = m_Inspector.Q <Button>("create-class-button"); m_ClassPillTemplate = BuilderPackageUtilities.LoadAssetAtPath <VisualTreeAsset>( BuilderConstants.UIBuilderPackagePath + "/BuilderClassPill.uxml"); m_AddClassButton.clickable.clicked += AddStyleClass; m_CreateClassButton.clickable.clicked += ExtractLocalStylesToNewClass; }
public BuilderInspector(BuilderPaneWindow paneWindow, BuilderSelection selection) { // Yes, we give ourselves a view data key. Don't do this at home! viewDataKey = "unity-ui-builder-inspector"; // Init External References m_Selection = selection; m_PaneWindow = paneWindow; // Load Template var template = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>( BuilderConstants.UIBuilderPackagePath + "/Inspector/BuilderInspector.uxml"); template.CloneTree(this); // Get the scroll view. // HACK: ScrollView is not capable of remembering a scroll position for content that changes often. // The main issue is that we expande/collapse/display/hide different parts of the Inspector // all the time so initially the ScrollView is empty and it restores the scroll position to zero. m_ScrollView = this.Q <ScrollView>("inspector-scroll-view"); m_ScrollView.contentContainer.RegisterCallback <GeometryChangedEvent>(OnScrollViewContentGeometryChange); m_ScrollView.verticalScroller.valueChanged += (newValue) => { CacheScrollPosition(newValue, m_ScrollView.verticalScroller.highValue); SaveViewData(); }; // Load styles. AddToClassList(s_UssClassName); styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(BuilderConstants.InspectorUssPathNoExt + ".uss")); if (EditorGUIUtility.isProSkin) { styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(BuilderConstants.InspectorUssPathNoExt + "Dark.uss")); } else { styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(BuilderConstants.InspectorUssPathNoExt + "Light.uss")); } // Matching Selectors m_MatchingSelectors = new BuilderInspectorMatchingSelectors(this); // Style Fields m_StyleFields = new BuilderInspectorStyleFields(this); // Sections m_Sections = new List <VisualElement>(); // Nothing Selected Section m_NothingSelectedSection = this.Q <Label>("nothing-selected-label"); m_Sections.Add(m_NothingSelectedSection); // Canvas Section m_CanvasSection = new BuilderInspectorCanvas(this); m_Sections.Add(m_CanvasSection.root); // StyleSheet Section m_StyleSheetSection = new BuilderInspectorStyleSheet(this); m_Sections.Add(m_StyleSheetSection.root); // Style Selector Section m_SelectorSection = new BuilderInspectorSelector(this); m_Sections.Add(m_SelectorSection.root); // Attributes Section m_AttributesSection = new BuilderInspectorAttributes(this); m_Sections.Add(m_AttributesSection.root); // Inherited Styles Section m_InheritedStyleSection = new BuilderInspectorInheritedStyles(this, m_MatchingSelectors); m_Sections.Add(m_InheritedStyleSection.root); // Local Styles Section m_LocalStylesSection = new BuilderInspectorLocalStyles(this, m_StyleFields); m_Sections.Add(m_LocalStylesSection.root); // This will take into account the current selection and then call RefreshUI(). SelectionChanged(); // Forward focus to the panel header. this.Query().Where(e => e.focusable).ForEach((e) => AddFocusable(e)); }