Version: 2020.2

GameObjectUtility.SetStaticEditorFlags

切换到手册
public static void SetStaticEditorFlags (GameObject go, StaticEditorFlags flags);

参数

go 要设置静态编辑器标志的 GameObject。
flags 要在 GameObject 上设置的 StaticEditorFlags。

描述

设置指定 GameObject 的 StaticEditorFlags。

StaticEditorFlags 确定哪些 Unity 系统将 GameObject 视为静态,并在 Unity 编辑器的预计算中包含 GameObject。在运行时设置 StaticEditorFlags 对这些系统没有影响。

有关更多信息,请参阅 Unity 手册文档中有关静态编辑器标志的内容

此示例中的代码为 GameObject 启用 Occludee StaticOccluder Static StaticEditorFlags:

using UnityEngine;
using UnityEditor;
public class StaticEditorFlagsExample
{
    [MenuItem("Examples/Create GameObject and set Static Editor Flags")]
    static void CreateGameObjectAndSetStaticEditorFlags()
    {
        // Create a GameObject
        var go = new GameObject("Example");
        // Set the GameObject's StaticEditorFlags
        var flags = StaticEditorFlags.OccluderStatic | StaticEditorFlags.OccludeeStatic;
        GameObjectUtility.SetStaticEditorFlags(go, flags);
    }
}
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961