Legacy Documentation: Version 2018.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.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

Submission failed

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

Close

Cancel

Description

Handler for message that is sent whenever the state of the project changes.

Actions that trigger this message include creating, renaming, or reparenting assets, as well as moving or renaming folders in the project. Note that the message is not sent immediately in response to these actions, but rather during the next update of the editor application.

Actions taken with assets that have HideFlags.HideInHierarchy set will not cause this message to be sent.

The OnProjectChange message is used to report when the items in the Project window change. Changes can include examples such as new GameObjects or Materials being added to the project. Additionally, adding folders with no contents will work as expected. As a final example OnProjectChange will be used to see any changes in the Project window.
See Also: EditorApplication.projectChanged.

no example available in JavaScript
// In this simple example MyClass adds an OnProjectChanged().  This is added
// using the projectWindowChanged.
// EditorApplication.projectWindowChanged can hold multiple calls including
// multiple OnProjectChanged calls.

using UnityEditor; using UnityEngine;

[InitializeOnLoad] class MyClass { static MyClass() { EditorApplication.projectWindowChanged += OnProjectChanged; }

static void OnProjectChanged() { Debug.Log("OnProjectChanged"); } }
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答