UnrealSharp
  • Home
  • FAQ
  • Getting Started
    • Setup
    • Your First Script
    • Debugging
    • Packaging
  • Documentation
    • Classes
      • Properties
        • C++ Functions As C# Properties
        • C++ Properties with Getters/Setters
      • Functions
        • Flags
        • MetaData
      • Default Actor Components
      • Helper Methods
    • Structs
    • Enums
    • Interfaces
    • Delegates
    • Collections
      • TArray
      • TNativeArray
      • TSet
      • TMap
    • Multiplayer
      • Replicated Properties
      • RPCs (Remote Procedure Calls)
      • Replicated UObjects
    • Primary Data Assets
      • Loading Primary Data Assets
    • Loading Soft References
    • Trace Channels
    • Static Variables
      • FWorldStaticVar<T>
      • FGameStaticVar<T>
    • Logging
    • Async
    • Gameplay Tags
      • Gameplay Tag Container
    • Extension / Mixin Methods
    • Subsystems
    • Module Lifecycle
  • Links
    • Github Repository
    • Roadmap
    • Discord
Powered by GitBook
On this page
  1. Documentation
  2. Primary Data Assets

Loading Primary Data Assets

All types registered in AssetManager settings are accessible in C# through the static AssetTypes class. These bindings make it easy to locate and load all assets of a specific type:

UAssetManager assetManager = UAssetManager.Get();

// Optional list of asset bundles to load
List<FName> bundles = new List<FName>();

// Load all primary assets of type ItemRecipe
IList<UItemRecipe> loadedItems = await assetManager.LoadPrimaryAssets<UItemRecipe>(AssetTypes.ItemRecipe.PrimaryAssetList, bundles);

To load specific assets, use the static AssetIds class or expose a UPropertyof type FPrimaryAssetIdand assign it in editor.

UAssetManager assetManager = UAssetManager.Get();

// Optional list of asset bundles to load
List<FName> bundles = new List<FName>();

// Loads Item_Axe primary asset.
UItem loadedItem = await assetManager.LoadPrimaryAsset<UItem>(AssetIds.Item_Item_Axe, bundles);

// Loads Item_Axe primary asset through assigned property.
UItem loadedItem = await assetManager.LoadPrimaryAsset<UItem>(AxeRecipeId, bundles);
PreviousPrimary Data AssetsNextLoading Soft References

Last updated 1 month ago