Hology
Hology
Hology
  • 👋Welcome to Hology Docs
  • Getting started
    • Introduction to Hology
    • The first steps
    • Editor basics
      • Flying in scenes
      • Placing objects
      • Select objects
      • Transform
      • Grouping objects
      • Duplicate
    • Starter project - Third person shooter
  • Tutorials
    • Rolling ball - Gameplay programming
    • Character movement programming
    • Character AI behavior
  • Release
    • Distribution
      • Discord Activities
      • Facebook Instant Games
      • Upload to Itch.io
      • Host with GitHub Pages
      • Publishing to Steam
      • iOS and Android
  • Assets
    • 3D Models
      • Custom collision shapes
      • Material slots
    • Materials
    • Textures
    • Prefabs
  • Gameplay
    • Actors
      • Creating actor classes
      • Actor parameters
      • Actor components
      • Actor lifecycle
      • Spawning actors
      • Moving actors
    • Services
      • Load assets
    • Player input
    • Collision detection
    • Physics
      • Physics body types
      • Applying forces
      • Ray casting
    • Trigger volumes
    • Character movement
    • Pointer events
    • Animation
      • Animation system
      • Character Animation
      • Animation State Machine
    • Sound
      • Audio parameter
    • World
    • Navigation
  • Shaders
    • Introduction to shaders
    • Creating shaders
    • Shader parameters
    • Typescript shaders
      • Types
      • Math functions
      • Attributes
      • Varying
      • Uniforms
      • Textures
      • Arrays
      • Select
      • Lighting
    • Painted materials
    • Water shader tutorial
  • Level design
    • Landscape sculpting
    • Landscape painting
    • Grass
  • User Interfaces
    • Creating user interfaces
    • Using React
    • VR
  • Visual Effects
    • Introduction to VFX
    • VFX Assets
  • Integrations
    • Arcweave
Powered by GitBook
On this page
  • Methods
  • getModelByAssetName(name: string): { scene, animations }
  • getModelByAssetId(id: string): { scene, animations }
  • getTextureByAssetName(name: string): Texture
  • getTextureByAssetId(id: string): Texture
  • getMaterialByAssetId(id: string): Material
  1. Gameplay
  2. Services

Load assets

You can use imported assets from code using the service AssetLoader which lets you get instances of an asset by name or id.

In the example below, we see how the AssetLoader is injected and used in the onInit method to get a model by name.

import { Actor, AssetLoader, BaseActor, inject } from "@hology/core/gameplay";

@Actor()
class TestActor extends BaseActor {

  assets = inject(AssetLoader)

  async onInit() {    
    const model = await this.assets.getModelByAssetName('enterNameHere')
    this.object.add(model.scene)
  }
}

Methods

getModelByAssetName(name: string): { scene, animations }

getModelByAssetId(id: string): { scene, animations }

getTextureByAssetName(name: string): Texture

getTextureByAssetId(id: string): Texture

getMaterialByAssetId(id: string): Material

PreviousServicesNextPlayer input

Last updated 5 months ago