Skip to content

Commit

Permalink
Added few options to context menu of ChefTools
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Suryś committed Nov 8, 2019
1 parent f3ff30d commit 6b0676f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
37 changes: 30 additions & 7 deletions Editor/ChefTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@

namespace QuickEye.BakingTools
{
public class ChefTools : EditorWindow
public class ChefTools : EditorWindow, IHasCustomMenu
{
public BakingMoldsLibrary library;
private const string _navMeshSettingsMenuPath = "Window/AI/Navigation";
private const string _lightingSettingsMenuPath = "Window/Rendering/Lighting Settings";
private const string _occlusionCullingSettingsMenuPath = "Window/Rendering/Occlusion Culling";

[SerializeField]
private BakingMoldsLibrary _library;

//DisplaySelected objects as baking properties list
//include list of materials
[MenuItem("CONTEXT/MeshRenderer/ChefTools")]
public static void OpenWindow(BakingMoldsLibrary lib)
{
var wnd = GetWindow<ChefTools>();
wnd.library = lib;
wnd._library = lib;
wnd.titleContent = new GUIContent("Chef Tools");
wnd.Init();
}

private void OnEnable()
{
if (library != null)
if (_library != null)
{
Init();
}
Expand All @@ -36,9 +40,9 @@ private void Init()
var scrollView = new ScrollView(ScrollViewMode.Vertical);
rootVisualElement.Add(scrollView);

var so = new SerializedObject(library);
var so = new SerializedObject(_library);
var list = new MoldsReorderableList(so, so.FindProperty("molds"));
list.applyButtonClickedEvent += i => OnApplyButtonClicked(library.molds[i]);
list.applyButtonClickedEvent += i => OnApplyButtonClicked(_library.molds[i]);
scrollView.Add(list);

var moldInspector = new VisualElement();
Expand Down Expand Up @@ -126,6 +130,25 @@ bool HasChildren()
}
}

public void AddItemsToMenu(GenericMenu menu)
{
menu.AddItem(new GUIContent("Lighting Settings"), false, OpenLightingSettings);
menu.AddItem(new GUIContent("Occlusion Settings"), false, OpenOcclusionSettings);
menu.AddItem(new GUIContent("Navigation Settings"), false, OpenNavigationSettings);
void OpenNavigationSettings()
{
EditorApplication.ExecuteMenuItem(_navMeshSettingsMenuPath);
}
void OpenLightingSettings()
{
EditorApplication.ExecuteMenuItem(_lightingSettingsMenuPath);
}
void OpenOcclusionSettings()
{
EditorApplication.ExecuteMenuItem(_occlusionCullingSettingsMenuPath);
}
}

public enum ShouldIncludeChildren
{
HasNoChildren = -1,
Expand Down
7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b0676f

Please sign in to comment.