private void ShowArt() { m_group ^= ToolbarGroup.Art; DisposeControls(~m_group); PopulateControls(m_group); }
private void ShowDesign() { m_group ^= ToolbarGroup.Design; DisposeControls(~m_group); PopulateControls(m_group); }
public AddToToolbarAttribute(string name, string tooltip, ToolbarGroup group = ToolbarGroup.Any, int order = 99) { m_name = name; m_order = order; m_group = group; m_tooltip = tooltip; }
private void ShowCode() { m_group ^= ToolbarGroup.Code; DisposeControls(~m_group); PopulateControls(m_group); }
/// <summary> /// Initialize the toolbar control. /// </summary> /// <param name="label">The button label and tooltip.</param> /// <param name="order">The order of the toggle in toolbar, 99 by default.</param> /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param> public void Init(string path, string name, string tooltip, int order, ToolbarGroup group) { m_order = order; m_group = group; m_label = new GUIContent(name, tooltip); hideFlags = HideFlags.HideAndDontSave; }
/// <summary> /// Dispose controls and remove them from the list. /// </summary> private void DisposeControls(ToolbarGroup group) { for (int i = m_controls.Count - 1; i >= 0; i--) { ToolbarControl control = m_controls [i]; if ((group & control.Group) == control.Group) { DestroyImmediate(control); m_controls.RemoveAt(i); } } }
private void PopulateControls(ToolbarGroup group) { foreach (Type type in Assembly.GetExecutingAssembly().GetTypes()) { AddToToolbarAttribute attribute = Attribute.GetCustomAttribute(type, typeof(AddToToolbarAttribute)) as AddToToolbarAttribute; // Skip types without attribute and that don't match category if (attribute == null || (group & attribute.Group) != attribute.Group) { continue; } // Skip types that are already in the list or not properly defined if (m_controls.Find(x => x.name == "" || x.name == attribute.Name)) { continue; } if (type.BaseType == typeof(EditorWindow)) { ToggleEditorWindow control = CreateInstance <ToggleEditorWindow> (); control.name = attribute.Name; control.Init(m_path, type, attribute.Name, attribute.Tooltip, attribute.Order, attribute.Group); m_controls.Add(control); } else if (type.BaseType == typeof(SceneWindow)) { ToggleSceneWindow control = CreateInstance <ToggleSceneWindow> (); control.name = attribute.Name; control.Init(m_path, type, attribute.Name, attribute.Tooltip, attribute.Order, attribute.Group); m_controls.Add(control); } else { ToolbarControl control = (ToolbarControl)CreateInstance(type); control.name = attribute.Name; control.Init(m_path, attribute.Name, attribute.Tooltip, attribute.Order, attribute.Group); m_controls.Add(control); } } // Sort controls by order m_controls.Sort((x, y) => (x.Order).CompareTo(y.Order)); }
/// <since>5.0</since> public ToolbarGroup GetGroup(string name) { int count = GroupCount; for (int i = 0; i < count; i++) { ToolbarGroup group = GetGroup(i); if (string.Compare(group.Name, name) == 0) { return(group); } } return(null); }
/// <summary> /// Initialize the scene window toggle. /// </summary> /// <param name="type">The type.</param> /// <param name="label">The button label and tooltip.</param> /// <param name="order">The order of the toggle in toolbar, 99 by default.</param> /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param> public void Init(string path, Type type, string name, string tooltip, int order, ToolbarGroup group) { m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/Icon" + name + ".png") as Texture; if (m_icon == null) { m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/IconDefault.png") as Texture; } m_order = order; m_group = group; m_type = type.AssemblyQualifiedName; m_label = new GUIContent(m_icon, tooltip); hideFlags = HideFlags.HideAndDontSave; }
/// <summary> /// Initialize the scene window toggle. /// </summary> /// <param name="type">The type.</param> /// <param name="label">The button label and tooltip.</param> /// <param name="order">The order of the toggle in toolbar, 99 by default.</param> /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param> public void Init(string path, Type type, string name, string tooltip, int order, ToolbarGroup group) { m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/Icon" + name + ".png") as Texture; if (m_icon == null) { m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/IconDefault.png") as Texture; } m_order = order; m_group = group; m_label = new GUIContent(m_icon, tooltip); hideFlags = HideFlags.HideAndDontSave; m_window = (SceneWindow)CreateInstance(type); m_window.hideFlags = HideFlags.HideAndDontSave; }
/** * Get the background button style for a toolbar group. */ public static GUIStyle GetStyle(ToolbarGroup group, bool isHorizontal) { if (group == ToolbarGroup.Tool) { return(GetBackgroundStyle("Tool", isHorizontal)); } else if (group == ToolbarGroup.Selection) { return(GetBackgroundStyle("Selection", isHorizontal)); } else if (group == ToolbarGroup.Object || group == ToolbarGroup.Entity) { return(GetBackgroundStyle("Object", isHorizontal)); } else // if( group == pb_ToolbarGroup.Geometry ) { return(GetBackgroundStyle("Geo", isHorizontal)); } }
/// <summary> /// Enable the toolbar window. /// </summary> private void OnEnable() { if (m_controls == null) { m_group = ToolbarGroup.All; minSize = new Vector2(30, 30); m_controls = new List <ToolbarControl> (); titleContent = new GUIContent("Toolbar", "A custom toolbar container."); // Load toolbar group if (EditorPrefs.HasKey("ToolbarGroup")) { m_group = (ToolbarGroup)EditorPrefs.GetInt("ToolbarGroup"); } m_path = AssetUtility.FindAssetPath("EditorToolbar", "t:Folder"); PopulateControls(m_group); } }
public static Color GetColor(ToolbarGroup group) { if (group == ToolbarGroup.Tool) { return(ToolColor); } else if (group == ToolbarGroup.Selection) { return(SelectionColor); } else if (group == ToolbarGroup.Object || group == ToolbarGroup.Entity) { return(ObjectColor); } else if (group == ToolbarGroup.Geometry) { return(GeometryColor); } return(Color.white); }
protected override void OnActivate() { base.OnActivate(); Start(); SearchPane.PropertyChanged += OnSearchPanePropertyChanged; ((IActivate)SearchPane).Activate(); if (_toolbarGroup == null) { _toolbarGroup = new ToolbarGroup(10) { new ToolbarAction(this, "Add", Add), new ToolbarAction(this, "Delete", Delete), new ToolbarAction(this, "Edit", Edit), new ToolbarAction(this, "Save", Save), new ToolbarAction(this, "Cancel", Cancel), new ToolbarAction(this, "Refresh", RefreshData) }; } _toolbar.AddGroup(_toolbarGroup); }
private async void StartAsync() { var mainGroup = new ToolbarGroup(0); _workspaces.OrderBy(w => w.Sequence).ForEach( w => mainGroup.Add(new ToolbarAction(this, w.DisplayName, async() => await NavigateToWorkspace(w)))); var logoutGroup = new ToolbarGroup(100) { new ToolbarAction(this, "Logout", Logout) }; Toolbar.Clear(); Toolbar.AddGroup(mainGroup); Toolbar.AddGroup(logoutGroup); var home = GetHomeScreen(); if (home != null) { await NavigateToWorkspace(home); } }
public void RemoveGroup(ToolbarGroup @group) { _groups.Remove(@group); NotifyOfPropertyChange(() => Actions); NotifyOfPropertyChange(() => Groups); }
public void AddGroup(ToolbarGroup @group) { _groups.Add(@group); NotifyOfPropertyChange(() => Actions); NotifyOfPropertyChange(() => Groups); }
/// <summary> /// /// </summary> /// <param name="menu"></param> private void ShowAll() { m_group = ToolbarGroup.All; PopulateControls(m_group); }