EditorUtility.IsPersistent 是否持久性

static function IsPersistent (target : Object) : bool


Determines if an object is stored on disk.


Typically assets like prefabs, textures, audio clips, animation clips, materials are stored on disk.

典型的资源像prefabs, textures, audio clips, animation clips, materials是存储在磁盘上。

Returns false if the object lives in the scene. Typically this is a game object or component but it could also be a material that was created from code and not stored in an asset but instead stored in the scene.

如果物体是活动在场景中返回false。典型的是game object或component,但也有可能是material,从代码创建并没有储存在资源中,而是储存在场景。

// Tells if an Object is stored on disk or not.
class PersistentInfo extends EditorWindow {

	@MenuItem("Examples/Object on Disk?")
	static function CheckPersistent() {
		var persistent : boolean = EditorUtility.IsPersistent(Selection.activeObject);
		Debug.Log(Selection.activeObject.name + ": " + persistent?"Stored on disk":"Not on disk");

	@MenuItem("Examples/Object on Disk?", true)
	static function ValidateCheckPersistent() {
		return Selection.activeObject != null;
Page last updated: 2011-7-15