Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

EditorWindow.OnProjectChange()

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual

Description

Called whenever the project has changed.

Typically after import, file moves, etc.


Force Sync with MonoDevelop each time the hierarchy or the project view changes.

	// Simple Editor Script that makes Unity Sync with MonoDevelop each time
	// there is a change in the Hierarchy or the Project view.
	
	class ForceSync extends EditorWindow {
	
		@MenuItem("Example/ForceSync When project changes")
		static function Init() {
			var window : ForceSync = EditorWindow.GetWindowWithRect(ForceSync, Rect(0,0,100, 100));
			window.Show();
		}
		function OnGUI() {
			if(GUILayout.Button("Sync now!"))
				EditorApplication.ExecuteMenuItem("Assets/Sync MonoDevelop Project");
		}
		function OnHierarchyChange() {
			EditorApplication.ExecuteMenuItem("Assets/Sync MonoDevelop Project");
			Debug.Log("Sync");
		}
		function OnProjectChange() {
			EditorApplication.ExecuteMenuItem("Assets/Sync MonoDevelop Project");
			Debug.Log("Sync");
		}
	}