Version: 2021.1

HideFlags.HideInHierarchy

切换到手册

描述

该对象不会显示在层级视图中。

using UnityEngine;

public class Example : MonoBehaviour { // Creates 5 planes and hides them from the Hierarchy in the Editor.

void Start() { for (int i = 0; i < 5; i++) { GameObject createdGO = GameObject.CreatePrimitive(PrimitiveType.Plane); createdGO.hideFlags = HideFlags.HideInHierarchy; } } }