构建场景后,将此属性添加至方法以接收通知。
A method with this attribute will also get called when entering Playmode, when Application.LoadLevel or Application.LoadLevelAdditive is called.
PostProcessSceneAttribute 具有提供回调中的顺序索引的选项,从 0 开始。如果您有多个 OnPostprocessScene 回调并想以特定顺序调用它们,此选项将非常有用。系统将从零开始按顺序调用回调。
// C# example: // Automatically creates a game object with a primitive mesh renderer and appropriate collider. using UnityEngine; using UnityEditor; using UnityEditor.Callbacks;
public class MyScenePostprocessor { [PostProcessSceneAttribute (2)] public static void OnPostprocessScene() { GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.transform.position = new Vector3(0.0f, 0.5f, 0.0f); } }