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); }