GithubHelp home page GithubHelp logo

lobosproger / addressable-sprite-loader Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 3 KB

Simple script for loading needing sprites from RAM for optimization! Based on Addressables system in Unity

License: MIT License

C# 100.00%

addressable-sprite-loader's Introduction

Addressable Sprite Loader

This script was developed in 2021 during the Quadroom game development. It utilizes the Unity Addressables system to load sprites into a SpriteRenderer from memory.

Usage

  1. Attach the AddressableSpriteLoader script to a GameObject in your Unity project.
  2. Assign a sprite asset using the loadableSpriteAsset field in the inspector.
  3. Attach a SpriteRenderer component to the same GameObject and assign it to the spriteRenderer field in the inspector.

Important Note

Make sure to mark the checkbox "Addressable" on the sprites you intend to load using this script.

Functions

LoadSpriteFromMemory

This function initiates the loading of the sprite from memory. It checks if the necessary fields (loadableSpriteAsset and spriteRenderer) are assigned before starting the loading process.

UnloadSpriteInMemory

This function unloads the sprite from memory by setting the sprite on the SpriteRenderer to null and releasing the handle obtained during loading.

LoadingSpriteFromMemory Coroutine

This coroutine handles the asynchronous loading of the sprite asset using Unity's Addressables system. Once loaded successfully, it sets the sprite on the SpriteRenderer.

addressable-sprite-loader's People

Contributors

lobosproger avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.