Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt

Use this file to discover all available pages before exploring further.

Folder: Assets/_MolcaSDK/Code/Scripts/Media/
TypeRole
MediaLoaderOrchestrates load/display
ImageHandler, VideoHandler, DocumentHandler, TextHandlerIMediaHandler implementations
UI: UI/MediaPreviewUI, MediaInfoCycle under Code/Scripts/UI/.

When to use

Use MediaLoader when you need authenticated download + cache for images, documents, or video URLs exposed by your backend, with optional loading modal progress via Modal manager. Not a substitute for raw Addressables or local Resources for built-in assets.

Code

MediaLoader is a RuntimeSubsystem; it requires AuthManager.IsAuthenticated for GetTexture (returns null if logged out). It uses HttpRequestAsset fields (getTexture2DRequest, getDocumentRequest, getVideoRequest) and CacheManager with version / cacheId.
using Molca;
using MolcaSDK.Media;
using UnityEngine;

public class SlideDeck : MonoBehaviour
{
    private async void Start()
    {
        await RuntimeManager.WaitForInitialization();
        var loader = RuntimeManager.GetSubsystem<MediaLoader>();
        if (loader == null) return;

        var texture = await loader.GetTexture("https://example.com/poster.png", version: 1);
        if (texture != null)
        {
            // Assign to RawImage / material
        }
    }
}
See MediaLoader.cs for document/video helpers and parity with the Inspector-configured request assets.

Troubleshooting

  • Always null texture — User must be logged in (AuthManager.IsAuthenticated); URL must be non-empty; getTexture2DRequest must be assigned.
  • Stale image after CDN update — Bump version so CacheManager.TryGetCache misses old bytes; or change cacheId.
  • Warning on init — Any of the three HttpRequestAsset references missing logs “Some HTTP request assets are not configured”; wire all three for production.
  • 401 / download errors — Request sets Bearer from AuthToken; renew session if tokens expire mid-session.

Unity Editor

Media Loader Inspector