/// <summary> /// /// </summary> protected override void OnBeginDrawEditors() { base.OnBeginDrawEditors(); OdinMenuItem selected = this.MenuTree.Selection.FirstOrDefault(); int toolbarHeight = this.MenuTree.Config.SearchToolbarHeight; SirenixEditorGUI.BeginHorizontalToolbar(toolbarHeight); { if (selected != null) { GUILayout.Label(selected.Name); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Switch Platform"))) { BuildManager.Instance.SwitchPlatform(selected.Name); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Upgrade Version"))) { VersionManager.Instance.UpdateVersion(); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Make a build", "Button used to make a build for current selected platform"))) { Close(); BuildManager.Instance.Build(); } } SirenixEditorGUI.EndHorizontalToolbar(); }
private void Drag(OdinMenuItem menuItem) { if (menuItem.IsSelected) { if (Event.current.type == EventType.MouseDown) { DragAndDrop.PrepareStartDrag(); DragAndDrop.StartDrag("elemnet"); var g = (menuItem.Value as Element).asset; DragAndDrop.objectReferences = new Object[1] { g }; } switch (Event.current.type) { case EventType.DragUpdated: case EventType.DragPerform: DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); } Event.current.Use(); break; default: break; } } }
public void AddProfileRecursive(IValidationProfile profile, OdinMenuItem menuItem = null) { menuItem = menuItem ?? this.RootMenuItem; var newMenuItem = new OdinMenuItem(this, profile.Name, profile) { Icon = profile.GetProfileIcon() }; this.childMenuItemLookup[profile] = newMenuItem; if (profile is ValidationProfileAsset) { var wrappedProfile = (profile as ValidationProfileAsset).GetWrappedProfile(); this.childMenuItemLookup[wrappedProfile] = newMenuItem; } menuItem.ChildMenuItems.Add(newMenuItem); foreach (var childProfile in profile.GetNestedValidationProfiles()) { this.AddProfileRecursive(childProfile, newMenuItem); } if (menuItem == this.RootMenuItem) { this.EnumerateTree().ForEach(x => x.Toggled = true); this.UpdateMenuTree(); } }
/// <summary> /// 单 Class 的按组添加 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="tree"></param> /// <param name="bigStr"></param> /// <param name="subString"></param> /// <param name="color"></param> protected void AddNew <R>(OdinMenuTree tree, string bigStr, string subString, MyEnumColor color = MyEnumColor.Blue) where R : new() { OdinMenuItem item1 = new OdinMenuItem(tree, subString, MyType.NewTypeClass <R>()); item1.TextColor = color; tree.AddMenuItemAtPath(bigStr, item1); }
void AddAllAssetsAtPath( OdinMenuTree tree, string assetFolderPath, Type type) { var strings = AssetDatabase.GetAllAssetPaths().Where(x => x.StartsWith(assetFolderPath, StringComparison.InvariantCultureIgnoreCase)); var odinMenuItemSet = new HashSet <OdinMenuItem>(); foreach (var str1 in strings) { var asset = AssetDatabase.LoadAssetAtPath(str1, type); var path = string.Empty; var name = string.Empty; var str2 = string.Empty; if (asset == null) { //it's a directory str2 = str1.Substring(assetFolderPath.Length); int length = str2.LastIndexOf('/'); if (length == -1) { path = string.Empty; name = str2; } else { path = str2.Substring(0, length); name = str2.Substring(length + 1); } if (name == string.Empty) { continue; } tree.AddMenuItemAtPath(odinMenuItemSet, path, new OdinMenuItem(tree, name, new FolderHolder(path, name))); continue; } var withoutExtension = System.IO.Path.GetFileNameWithoutExtension(str1); str2 = (PathUtilities.GetDirectoryName(str1).TrimEnd('/') + "/").Substring(assetFolderPath.Length); if (str2.Length != 0) { path = path.Trim('/') + "/" + str2; } path = path.Trim('/') + "/" + withoutExtension; SplitMenuPath(path, out path, out name); var menuItem = new OdinMenuItem(tree, name, new DataNodeHolder(path, name, (DataNode)asset)); tree.AddMenuItemAtPath(odinMenuItemSet, path, menuItem); AddDragHandles(menuItem); } }
public void BuildTree(object obj) { OdinMenuItem selected = this.Selection.FirstOrDefault(); if (selected != null && selected.Value != obj) { OdinMenuItem menuItem = this.EnumerateTree().FirstOrDefault(n => n.Value == obj); if (menuItem != null) { menuItem.Select(); } } }
protected override void Initialize() { this.menuTreeWidth = this.GetPersistentValue <float>("menuTreeWidth", 380); this.columns = new List <ResizableColumn>() { ResizableColumn.FlexibleColumn(this.menuTreeWidth.Value, 80), ResizableColumn.DynamicColumn(0, 200) }; this.runner = new ValidationRunner(); this.overview = new ValidationOverview(); this.editor = this.ValueEntry.SmartValue; this.profile = this.editor.Profile; this.sourceProperty = this.Property.Children["selectedSourceTarget"]; this.validationProfileTree = new ValidationProfileTree(); this.overviewToggle = this.GetPersistentValue <bool>("overviewToggle", true); this.validationProfileTree.Selection.SelectionChanged += (x) => { if (x == SelectionChangedType.ItemAdded) { object value = this.validationProfileTree.Selection.SelectedValue; ValidationProfileResult result = value as ValidationProfileResult; if (result != null) { this.editor.SetTarget(result.GetSource()); } else { this.editor.SetTarget(value); } } }; this.overview.OnProfileResultSelected += result => { OdinMenuItem mi = this.validationProfileTree.GetMenuItemForObject(result); mi.Select(); object source = result.GetSource(); this.editor.SetTarget(source); }; this.validationProfileTree.AddProfileRecursive(this.ValueEntry.SmartValue.Profile); OdinMenuTree.ActiveMenuTree = this.validationProfileTree; if (this.editor.ScanProfileImmediatelyWhenOpening) { this.editor.ScanProfileImmediatelyWhenOpening = false; this.ScanProfile(this.editor.Profile); } }
private void ModifyModelName() { var models = new List <string>(CfgManager.Model.Keys); models.Remove(ModelName); SimplePopupCreator.ShowDialog(new List <string>(models), (name) => { _actorCfg.ModelName = name; ActorEditorWindow window = ActorEditorWindow.GetWindow <ActorEditorWindow>(); OdinMenuItem item = window.MenuTree.Selection.FirstOrDefault(); item.Name = name; item.SearchString = name; }); }
protected override void OnBeginDrawEditors() { OdinMenuItem selected = null; try { if (this.MenuTree.Selection.Count > 0) { selected = this.MenuTree.Selection.FirstOrDefault(); } } catch (NullReferenceException) { } int toolbarHeight = 0; if (this.MenuTree.Config.SearchToolbarHeight != null) { toolbarHeight = this.MenuTree.Config.SearchToolbarHeight; } // Draws a toolbar with the name of the currently selected menu item. SirenixEditorGUI.BeginHorizontalToolbar(toolbarHeight); { if (selected != null) { GUILayout.Label(selected.Name); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Create Loadout"))) { ScriptableObjectPicker.ShowDialog <Loadout>("Assets/Resources/Equipment/Loadouts", obj => { obj.Name = obj.name; base.TrySelectMenuItemWithObject(obj); // Selects the newly created item in the editor }); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Create Equipment"))) { ScriptableObjectPicker.ShowDialog <Equipment>("Assets/Resources/Equipment", obj => { obj.Name = obj.name; base.TrySelectMenuItemWithObject(obj); // Selects the newly created item in the editor }); } } SirenixEditorGUI.EndHorizontalToolbar(); }
public static void BuildMenuTree(OdinMenuTree tree) { foreach (var allTrickOverViewInfo in AllTrickOverViewExamples) { TrickOverViewInfo trickOverViewInfo = (allTrickOverViewInfo.Value).GetTrickOverViewInfo(); OdinMenuItem menuItem = new OdinMenuItem(tree, trickOverViewInfo.Name, allTrickOverViewInfo.Key) { Value = allTrickOverViewInfo.Key, SearchString = trickOverViewInfo.Name + trickOverViewInfo.Description }; tree.AddMenuItemAtPath(trickOverViewInfo.Category, menuItem); } tree.MenuItems.Sort(AllTrickOverViewUtilities.CategorySorter); tree.MarkDirty(); }
protected override void OnBeginDrawEditors() { OdinMenuItem selected = null; if (MenuTree != null) { if (MenuTree.MenuItems.Count > 0) { selected = this.MenuTree.Selection.FirstOrDefault(); } var toolbarHeight = this.MenuTree.Config.SearchToolbarHeight; // Draws a toolbar with the name of the currently selected menu item. SirenixEditorGUI.BeginHorizontalToolbar(toolbarHeight); { if (selected != null) { //GUILayout.Label(((GameEventListener)selected.ObjectInstance).name + " > " + selected.Name); //GUILayout.Label(selected.Name); if (SirenixEditorGUI.ToolbarButton(new GUIContent("Select GameObject"))) { Selection.activeGameObject = (((UniTweenSequence)selected.ObjectInstance).gameObject); } } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Reload Tree"))) { ForceMenuTreeRebuild(); } } SirenixEditorGUI.EndHorizontalToolbar(); } else { if (SirenixEditorGUI.ToolbarButton(new GUIContent("Reload Tree"))) { ForceMenuTreeRebuild(); } } }
public static void BuildMenuTree(OdinMenuTree tree) { foreach (var a in GetAllOdinAttributes()) { string search = a.Name; // TODO: tags? foreach (var c in GetAttributeCategories(a)) { var item = new OdinMenuItem(tree, a.GetNiceName().Replace("Attribute", "").SplitPascalCase(), a) { Value = a, Icon = GetAttributeIcon(a), SearchString = search, }; search = null; // Only allow the user to find the first item of an attribute by search. tree.AddMenuItemAtPath(c, item); } } tree.SortMenuItemsByName(); }
protected override void OnBeginDrawEditors() { OdinMenuItem selected = null; if (MenuTree != null) { if (MenuTree.MenuItems.Count > 0) { selected = this.MenuTree.Selection.FirstOrDefault(); } var toolbarHeight = this.MenuTree.Config.SearchToolbarHeight; SirenixEditorGUI.BeginHorizontalToolbar(toolbarHeight); { if (selected != null) { if (SirenixEditorGUI.ToolbarButton(new GUIContent("Select GameObject"))) { Selection.activeGameObject = (((UniTweenSequencePlayer)selected.Value).gameObject); EditorGUIUtility.PingObject(Selection.activeGameObject); } } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Reload Tree"))) { ForceMenuTreeRebuild(); } } SirenixEditorGUI.EndHorizontalToolbar(); } else { if (SirenixEditorGUI.ToolbarButton(new GUIContent("Reload Tree"))) { ForceMenuTreeRebuild(); } } }
public void Delete() { if (EditorUtility.DisplayDialog("删除操作", "确定要删除文件 -> " + ModelName, "确定", "取消")) { if (File.Exists(_path)) { File.Delete(_path); } ActorEditorWindow window = ActorEditorWindow.GetWindow <ActorEditorWindow>(); OdinMenuItem item = window.MenuTree.Selection.FirstOrDefault(); if (item != null && item.Value != null) { ActorEditor model = item.Value as ActorEditor; HomeConfig.Instance.RemoveActor(model); item.Parent.ChildMenuItems.Remove(item); item.MenuTree.Selection.Clear(); item.Parent.Select(); item.MenuTree.UpdateMenuTree(); item.MenuTree.DrawMenuTree(); } } }
public static void BuildMenuTree(OdinMenuTree tree) { foreach (var a in GetAllOdinAttributes()) { // TODO: tags? string search = a.Name + " " + string.Join(" ", GetAttributeExampleInfos(a).Select(x => x.Name).ToArray()); foreach (var c in GetAttributeCategories(a)) { var item = new OdinMenuItem(tree, a.GetNiceName().Replace("Attribute", "").SplitPascalCase(), a) { Value = a, SearchString = search, }; search = null; // Only allow the user to find the first item of an attribute by search. tree.AddMenuItemAtPath(c, item); } } tree.MenuItems.Sort(CategorySorter); tree.MarkDirty(); }
public ValidationProfileTree() { this.Config.DrawSearchToolbar = true; this.Config.AutoHandleKeyboardNavigation = true; this.Config.UseCachedExpandedStates = false; this.DefaultMenuStyle = OdinMenuStyle.TreeViewStyle; this.childMenuItemLookup = new Dictionary <object, OdinMenuItem>(); this.Selection.SelectionConfirmed += (x) => { OdinMenuItem sel = x.FirstOrDefault(); if (sel != null && sel.Value is ValidationProfileResult) { ValidationProfileResult result = sel.Value as ValidationProfileResult; if (result != null) { UnityEngine.Object source = result.GetSource() as UnityEngine.Object; GUIHelper.SelectObject(source); } } }; }
public void Delete() { if (EditorUtility.DisplayDialog("删除操作", "确定要删除文件 -> " + ModelName, "确定", "取消")) { if (File.Exists(_path)) { File.Delete(_path); } ModelCfgWindow window = ModelCfgWindow.GetWindow <ModelCfgWindow>(); OdinMenuItem item = window.MenuTree.Selection.FirstOrDefault(); if (item != null) { ModelActionConfigEditor model = item.ObjectInstance as ModelActionConfigEditor; HomeConfigPreview.Instance.RemoveModel(model); item.Parent.ChildMenuItems.Remove(item); item.MenuTree.Selection.Clear(); item.Parent.Select(); item.MenuTree.UpdateMenuTree(); item.MenuTree.DrawMenuTree(); } } }
protected override void OnBeginDrawEditors() { OdinMenuItem selected = this.MenuTree.Selection.FirstOrDefault(); int toolbarHeight = this.MenuTree.Config.SearchToolbarHeight; // Draws a toolbar with the name of the currently selected menu item. SirenixEditorGUI.BeginHorizontalToolbar(toolbarHeight); { if (selected != null) { GUILayout.Label(selected.Name); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Add Zone"))) { PathSettings.AddZone(ProceduralZone.Default); //base.TrySelectMenuItemWithObject(zone); } if (SirenixEditorGUI.ToolbarButton(new GUIContent("Delete Zone")) && PathSettings.Zones.Count > 0) { //ProceduralZone zone = selected.Value as ProceduralZone; //PathSettings.RemoveZone(zone); //AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(zone)); //base.TrySelectMenuItemWithObject(PathSettings); //if (PathSettings.Zones.Count > 0) // base.TrySelectMenuItemWithObject(PathSettings.Zones.Last()); //base.MenuTree.MarkDirty(); } } SirenixEditorGUI.EndHorizontalToolbar(); }
private void AddDragHandles(OdinMenuItem menuItem) { menuItem.OnDrawItem += x => DragAndDropUtilities.DragZone(menuItem.Rect, menuItem.Value, false, false); }
public void AddDragHandles(OdinMenuItem item) { item.OnDrawItem += (t) => { (t.Value as EnemyConfig).SetEditorSprite(); (t.Value as EnemyConfig).SetEditorPrefab(); }; }
public void AddResultToTree(ValidationProfileResult result) { if (result.Results == null) { return; } if (result.Results.Any(x => x.ResultType != ValidationResultType.Valid)) { var menuItem = new OdinMenuItem(this, result.Name, result); var scene = default(Scene); if (result.Source as UnityEngine.Object) { var component = result.Source as Component; var go = result.Source as GameObject; if (component) { go = component.gameObject; } if (go) { scene = go.scene; } } this.childMenuItemLookup[result] = menuItem; if (result.Profile != null && scene.IsValid() && !this.childMenuItemLookup.ContainsKey(scene.path) && this.childMenuItemLookup.ContainsKey(result.Profile)) { var sceneItem = new OdinMenuItem(this, scene.name, scene.path); sceneItem.IconGetter = () => EditorIcons.UnityLogo; sceneItem.Toggled = true; this.childMenuItemLookup.Add(scene.path, sceneItem); this.childMenuItemLookup[result.Profile].ChildMenuItems.Add(sceneItem); } if (scene.IsValid() && this.childMenuItemLookup.ContainsKey(scene.path)) { this.childMenuItemLookup[scene.path].ChildMenuItems.Add(menuItem); } else if (result.Profile == null || !this.childMenuItemLookup.ContainsKey(result.Profile)) { this.MenuItems.Add(menuItem); } else { this.childMenuItemLookup[result.Profile].ChildMenuItems.Add(menuItem); } if (result.Source != null) { var component = result.Source as UnityEngine.Component; if (component) { menuItem.Icon = GUIHelper.GetAssetThumbnail(component.gameObject, null, false); } else { menuItem.Icon = GUIHelper.GetAssetThumbnail(result.Source as UnityEngine.Object, result.Source.GetType(), false); } } else { menuItem.Icon = EditorIcons.Transparent.Active; } } }
private void AddDragHandles(OdinMenuItem menuItem) { menuItem.OnDrawItem += x => Drag(menuItem); }
public void AddDragHandles <T>(OdinMenuItem item) where T : ItemConfig <T> { item.OnDrawItem += (t) => { (t.Value as T).SetEditorSprite(); }; }
public void AddDragHandles(OdinMenuItem item) { item.OnDrawItem += (t) => { (t.Value as SkillConfig).SetEditorSprite(); }; }