EditorUtility.IsPersistent 是否持久性

static function IsPersistent (target : Object) : bool

Description描述

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;
	}
}
最后修改:2011年7月15日 Friday 14:33

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。