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)