ひきぷろのプログラミング日記

プログラミングの日記です。

(Unity) Project Settings を簡単に開くことができるようにする

メニューから、 Edit -> Project Settings ... と、たどるのが面倒なので、検索してみました。

Menu で表示する

baba-s.hatenablog.com

Window で表示する

panzersoft.blog.fc2.com

もうちょっと改良

どちらも便利なので、コピペで簡単に使えるように、もう少しだけ改良してみました。

Menu で表示する

f:id:hikipuro:20161017143914p:plain

// ProjectSettingsShortcuts.cs
#if UNITY_EDITOR
using UnityEditor;

public class ProjectSettingsShortcuts {
	const string MenuTitle = "Project Settings";

	[MenuItem(MenuTitle + "/Input")]
	public static void Input() {
		OpenProjectSettingsMenu("Input");
	}

	[MenuItem(MenuTitle + "/Tags and Layers")]
	public static void TagsAndLayers() {
		OpenProjectSettingsMenu("Tags and Layers");
	}

	[MenuItem(MenuTitle + "/Audio")]
	public static void Audio() {
		OpenProjectSettingsMenu("Audio");
	}

	[MenuItem(MenuTitle + "/Time")]
	public static void Time() {
		OpenProjectSettingsMenu("Time");
	}

	[MenuItem(MenuTitle + "/Player")]
	public static void Player() {
		OpenProjectSettingsMenu("Player");
	}

	[MenuItem(MenuTitle + "/Physics")]
	public static void Physics() {
		OpenProjectSettingsMenu("Physics");
	}

	[MenuItem(MenuTitle + "/Physics 2D")]
	public static void Physics2D() {
		OpenProjectSettingsMenu("Physics 2D");
	}

	[MenuItem(MenuTitle + "/Quality")]
	public static void Quality() {
		OpenProjectSettingsMenu("Quality");
	}

	[MenuItem(MenuTitle + "/Graphics")]
	public static void Graphics() {
		OpenProjectSettingsMenu("Graphics");
	}

	[MenuItem(MenuTitle + "/Network")]
	public static void Network() {
		OpenProjectSettingsMenu("Network");
	}

	[MenuItem(MenuTitle + "/Editor")]
	public static void Editor() {
		OpenProjectSettingsMenu("Editor");
	}

	[MenuItem(MenuTitle + "/Script Execution Order")]
	public static void ScriptExecutionOrder() {
		OpenProjectSettingsMenu("Script Execution Order");
	}

	private static void OpenProjectSettingsMenu(string name) {
		EditorApplication.ExecuteMenuItem("Edit/Project Settings/" + name);
	}
}
#endif

Window で表示する

f:id:hikipuro:20161017143916p:plain

// ProjectSettingsWindow.cs
using UnityEngine;
using UnityEditor;

public class ProjectSettingsWindow : EditorWindow {
	[MenuItem("Window/Project Settings")]
	static void Init() {
		ProjectSettingsWindow window = GetWindow<ProjectSettingsWindow>("Project Settings");
		window.ShowPopup();
	}

	void OnGUI() {
		EditorGUILayout.BeginVertical();

		EditorGUILayout.LabelField("Project Settings", EditorStyles.boldLabel);
		if (GUILayout.Button("Player")) {
			OpenProjectSettingsMenu("Player");
		}
		if (GUILayout.Button("Quality")) {
			OpenProjectSettingsMenu("Quality");
		}
		if (GUILayout.Button("Input")) {
			OpenProjectSettingsMenu("Input");
		}
		if (GUILayout.Button("Tags and Layers")) {
			OpenProjectSettingsMenu("Tags and Layers");
		}
		if (GUILayout.Button("Audio")) {
			OpenProjectSettingsMenu("Audio");
		}
		if (GUILayout.Button("Time")) {
			OpenProjectSettingsMenu("Time");
		}
		if (GUILayout.Button("Physics")) {
			OpenProjectSettingsMenu("Physics");
		}
		if (GUILayout.Button("Physics 2D")) {
			OpenProjectSettingsMenu("Physics 2D");
		}
		if (GUILayout.Button("Graphics")) {
			OpenProjectSettingsMenu("Graphics");
		}
		if (GUILayout.Button("Network")) {
			OpenProjectSettingsMenu("Network");
		}
		if (GUILayout.Button("Editor")) {
			OpenProjectSettingsMenu("Editor");
		}
		if (GUILayout.Button("Script Execution Order")) {
			OpenProjectSettingsMenu("Script Execution Order");
		}
		
		EditorGUILayout.EndVertical();
	}

	private static void OpenProjectSettingsMenu(string name) {
		EditorApplication.ExecuteMenuItem("Edit/Project Settings/" + name);
	}
}

Window で表示する方は、 Editor フォルダに入れると動くと思います。