https://github.com/udfsoft/glideunity
GlideUnity is a lightweight and easy to use wrapper for loading images into Unity
https://github.com/udfsoft/glideunity
csharp glide image loader unity
Last synced: about 1 month ago
JSON representation
GlideUnity is a lightweight and easy to use wrapper for loading images into Unity
- Host: GitHub
- URL: https://github.com/udfsoft/glideunity
- Owner: UDFSoft
- License: apache-2.0
- Created: 2025-06-23T20:07:17.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-23T20:18:58.000Z (12 months ago)
- Last Synced: 2025-06-23T21:29:25.367Z (12 months ago)
- Topics: csharp, glide, image, loader, unity
- Language: C#
- Homepage: https://udfsoft.com
- Size: 12.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GlideUnity
**GlideUnity** is a lightweight and convenient wrapper for loading images in Unity, inspired by [Glide for Android](https://github.com/bumptech/glide). It supports loading from the network, file system, and Resources folder, with memory/disk caching, placeholders, and error handling.
## ๐ Features
- โ
Load images from:
- Network (`http/https`)
- File system (`file://`)
- Unity `Resources` folder
- โ
Supports Unity UI components:
- `RawImage`
- `Image` (`Sprite`)
- โ
Caching:
- In-memory (RAM) with LRU eviction
- On disk (`Application.persistentDataPath`)
- โ
Placeholders and error images
- โ
Custom HTTP headers
- โ
Safe handling of `null` and empty paths
---
## ๐ง Installation
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.UI` where needed to use Unity UI components.
---
## ๐งช Example Usage
```csharp
Glide.With(this)
.Load("https://example.com/avatar.png")
.Placeholder(myPlaceholderTexture)
.Error(myErrorTexture)
.Header("Authorization", "Bearer xyz")
.Into(myRawImage);
```
Or for Image (Sprite):
```csharp
Glide.With(this)
.Load("https://example.com/icon.png")
.Placeholder(spriteTexture)
.Into(myUIImage);
```
## ๐ฆ Caching
### ๐ง In-Memory
LRU cache (default limit: 5 images)
Manually clear:
```csharp
ImageCache.ClearMemory();
```
### ๐พ On-Disk
Stored at Application.persistentDataPath/image_cache
Not automatically cleared (by default)
Manually clear:
```csharp
ImageCache.ClearDisk();
```
### ๐ Safety
Load(null) and Load("") are safely handled
If the path is invalid or loading fails, the placeholder or errorImage is shown (if provided)