Editor.Assets.ObjectPrefab
ClassReusable object template that can be instantiated in scenes.
Index
Properties
Methods
Example
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const assetManager = model.project.assetManager;
// Find all ObjectPrefab assets in the project
const prefabs = assetManager.assets.filter(
a => a.isOfType('ObjectPrefab')
) as Editor.Assets.ObjectPrefab[];
// Inspect each prefab's lazyLoading/retainAssets flags and instances
let totalInstances = 0;
for (const prefab of prefabs) {
totalInstances += prefab.prefabInstances.length;
}
console.log(`Total prefabs: ${prefabs.length}, total instances: ${totalInstances}`);
Extends
Properties
cacheFile
readonlycacheFile:Path
Path to the cached asset file.
Inherited from
fileMeta
readonlyfileMeta:AssetImportMetadata
Import metadata for the asset.
Inherited from
id
readonlyid:Uuid
The unique id of the entity.
Inherited from
lazyLoading
lazyLoading:
boolean
Whether prefab assets load lazily on first use.
meta
readonlymeta:Meta
Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.
Inherited from
name
readonlyname:string
The name of the asset.
Inherited from
prefabInstances
readonlyprefabInstances:SceneObject[]
List of scene objects instantiated from this prefab.
retainAssets
retainAssets:
boolean
Whether referenced assets are preserved when the prefab is modified.
rootSceneObjects
readonlyrootSceneObjects:SceneObject[]
A list of scene objects which is a direct child of this entity.
Inherited from
sceneObjects
readonlysceneObjects:SceneObject[]
A list of scene objects which is a child of this entity.
Inherited from
type
readonlytype:string
The entity's type.
Inherited from
Methods
addSceneObject()
addSceneObject(
parent):SceneObject
Adds a scene object to the entity.
Parameters
| Parameter | Type |
|---|---|
parent | SceneObject |
Returns
Inherited from
apply()
apply():
void
Applies edits made directly to the prefab asset's root object to the prefab and propagates them to all of its instances. Does nothing if the prefab has no root object.
Returns
void
createSceneObject()
createSceneObject(
name):SceneObject
Creates a scene object to the entity.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
Inherited from
findComponents()
findComponents(
entityType):Component[]
Find components on the entity.
Parameters
| Parameter | Type |
|---|---|
entityType | string |
Returns
Inherited from
getDirectlyReferencedEntities()
getDirectlyReferencedEntities():
Entity[]
A list of entities which this entity has a reference to.
Returns
Entity[]
Inherited from
ObjectOwner.getDirectlyReferencedEntities
getMeta()
staticgetMeta():Meta
Returns metadata about this type.
Returns
Inherited from
getOwnedEntities()
getOwnedEntities():
Entity[]
A list of entities which has a reference to this entity.
Returns
Entity[]
Inherited from
getRootObjectIndex()
getRootObjectIndex(
object):number
Get the index of object within the list of all the root objects.
Parameters
| Parameter | Type |
|---|---|
object | SceneObject |
Returns
number
Inherited from
ObjectOwner.getRootObjectIndex
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
reparentSceneObject()
reparentSceneObject(
object,newParent,position?):void
Reparent the scene object to another scene object. You can use this to reparent objects to the root (i.e. pass in null).
Parameters
| Parameter | Type |
|---|---|
object | SceneObject |
newParent | SceneObject |
position? | number |
Returns
void