Legacy Documentation: Version 2017.1 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

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

EditorWindow.OnHierarchyChange()

Description

Called whenever the scene hierarchy has changed.

This is transform.parent changed, gameObject.name, creating a new game object, 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"); } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答