Version: 2021.1
언어: 한국어

EditorWindow.OnProjectChange()

매뉴얼로 전환

설명

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.

// 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"); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961