AssetService
Load models and preload content assets.
- Service
game:GetService("AssetService")- Inherits
- Instance
- Replication
- Never
Behavior
AssetService provides asset loading and caching operations. Asset requests may
yield. Content identifiers may use astassetid://, rbxassetid://,
astasset://, rbxasset://, http://, or https:// forms.
Summary
Creates an EditableImage.
Returns this instance if it is an ExecutionGroup.
Returns the number of shaders waiting for compilation.
Returns an Enum.AssetStatus value for a content identifier.
Preload(contentIds: { string | Instance }, callback: ((contentId: string, status: EnumItem) -> ())?): ()serial onlyRequests one or more content identifiers and yields until all uncached requests in the batch finish.
Methods
CreateEditableImage
AssetService:CreateEditableImage(options: { Size: Vector2? }?): EditableImageCreates an EditableImage. The optional Size entry specifies its pixel dimensions.
GetExecutionGroup
AssetService:GetExecutionGroup(): ExecutionGroup?Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.
GetPendingShaderCount
AssetService:GetPendingShaderCount(): numberReturns the number of shaders waiting for compilation.
GetStatus
AssetService:GetStatus(content: string): EnumItemReturns an Enum.AssetStatus value for a content identifier. It reports whether the asset is not requested, loading, loaded, or failed.
Preload
AssetService:Preload(contentIds: { string | Instance }, callback: ((contentId: string, status: EnumItem) -> ())?): ()Requests one or more content identifiers and yields until all uncached requests in the batch finish. Duplicate identifiers are requested once. A batch may contain up to 1,024 identifiers.
Inherited members
- Properties
- ArchivableClassNameNameParent
- Methods
- AddComponent()AddTag()ClearAllChildren()ClearTags()Clone()Destroy()FindFirstAncestor()FindFirstAncestorOfClass()FindFirstAncestorWhichIsA()FindFirstChild()FindFirstChildOfClass()FindFirstChildWhichIsA()FindFirstDescendant()GetAttribute()GetAttributeChangedSignal()GetAttributes()GetChildren()GetComponent()GetComponentChangedSignal()GetComponents()GetDebugId()GetDescendants()GetFullName()GetPropertyChangedSignal()GetReferencing()GetTags()HasComponent()HasTag()IsA()IsAncestorOf()IsDescendantOf()RemoveComponent()RemoveTag()SetAttribute()WaitForChild()
- Events
- AncestryChangedAttributeChangedChangedChildAddedChildRemovedDescendantAddedDescendantRemovingDestroying
Example
local assets = game:GetService("AssetService")
assets:Preload({ "astassetid://10", "astassetid://20" })
local status = assets:GetStatus("astassetid://10")