Skip to content

UDFSoft/GlideUnity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GlideUnity

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.

πŸš€ 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

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);

πŸ“¦ Caching

🧠 In-Memory

LRU cache (default limit: 5 images)

Manually clear:

ImageCache.ClearMemory();

πŸ’Ύ On-Disk

Stored at Application.persistentDataPath/image_cache

Not automatically cleared (by default)

Manually clear:

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)

About

GlideUnity is a lightweight and easy to use wrapper for loading images into Unity

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages