Skip to content

namquang93/CustomTiledImage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Tiled Image

Intro

This is a small script that helps you to customize tiled image easier. Right now we can only have a tiled image to flip.

Intro

How to use

Simply add the component to an UI gameobject, assign a sprite to it and then check Flip Horizontal When Tiled or Flip Vertical When Tiled.

How it works

AlleyLabs.Engine.CustomTiledImage extends UnityEngine.UI.Image and override the method OnPopulateMesh to change the behavior when the image is tiled. The trick is to swap the uvMin and uvMax when the tile index is odd.

if (flipH) {
    var tmp = uvMin.x;
    uvMin.x = uvMax.x;
    uvMax.x = tmp;
}
 
if (flipV) {
    var tmp = uvMin.y;
    uvMin.y = uvMax.y;
    uvMax.y = tmp;
}

License

This project is licensed under the MIT License - see the LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages