HideFlags.DontSave 不保存
Description描述
The object will not be saved to the scene. It will not be destroyed when a new scene is loaded.
该物体将不能保存到场景。当一个新的场景被加载,它也不会被销毁。
It is your responsibility to cleanup the object manually using DestroyImmediate, otherwise it will leak.
你可以手动使用DestroyImmediate清理物体,否则会泄漏。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Start() {
GameObject notDestructable = GameObject.CreatePrimitive(PrimitiveType.Plane);
notDestructable.hideFlags = HideFlags.DontSave;
}
}
// Instantiates a Plane everytime the game starts and never destroys it
//在每次游戏开始实例化一个平面,并用不销毁
// even if you stop your game preview
//即使你停止游戏预览
// NOTE: Watch out, this can cause LEAKS
//注意:小心,这可能会导致是否泄漏
function Start() {
var notDestructable : GameObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
notDestructable.hideFlags = HideFlags.DontSave;
}
最后修改:2011年5月10日 Tuesday 9:42