GlideUnity is a lightweight and convenient wrapper for loading images in Unity, inspired by Glide for Android. It supports loading from the network, file system, and Resources folder, with memory/disk caching, placeholders, and error handling.
- β
Load images from:
- Network (
http/https) - File system (
file://) - Unity
Resourcesfolder
- Network (
- β
Supports Unity UI components:
RawImageImage(Sprite)
- β
Caching:
- In-memory (RAM) with LRU eviction
- On disk (
Application.persistentDataPath)
- β Placeholders and error images
- β Custom HTTP headers
- β
Safe handling of
nulland empty paths
Copy the following files into your Unity project:
Assets/Scripts/GlideUnity/
βββ Glide.cs
βββ GlideRequestBuilder.cs
βββ GlideLoader.cs
βββ ImageRequest.cs
βββ ImageSourceType.cs
βββ ImageCache.cs
π Make sure to include
using UnityEngine.UIwhere needed to use Unity UI components.
Glide.With(this)
.Load("https://example.com/avatar.png")
.Placeholder(myPlaceholderTexture)
.Error(myErrorTexture)
.Header("Authorization", "Bearer xyz")
.Into(myRawImage);Or for Image (Sprite):
Glide.With(this)
.Load("https://example.com/icon.png")
.Placeholder(spriteTexture)
.Into(myUIImage);LRU cache (default limit: 5 images)
Manually clear:
ImageCache.ClearMemory();Stored at Application.persistentDataPath/image_cache
Not automatically cleared (by default)
Manually clear:
ImageCache.ClearDisk();Load(null) and Load("") are safely handled
If the path is invalid or loading fails, the placeholder or errorImage is shown (if provided)