Unity Scripts Added (For Game Devs!) Finally!!


Hello everyone!

It's been a while since I've uploaded anything! Don't worry it's not because I moved on from unity and dev-life. I've been working on personal projects this whole while when I finally decided to get around to making this plugin (technically just a script but whatever).

As an added bonus I've implemented an integrated close-up portrait feature into the Portrait Renamer app that allows you to specify  coordinates on each image that get referenced by the PortraitReader script to dynamically generate a closeup image of that character.

No more will you need to create 2 seperate files for full-body and close-up images!

You will be wondering how to use this.

Instructions:

App Users:

When loading the app you will find a new section in the middle where a toggle named "Enable Portrait Cropping" exists. 

If you enable that the new feature will start working.

Selecting a loaded image will now preview a close-up shot of that character (Sometimes will look like nothing has changed because it is generating a preview from a transparent region of the character image).

You can now tweak the X and Y coord fields to get the cropping exactly how you want it.

Note: 

The XY coords are the bottom left corner of the crop so you need to add the box resolution to get the top right corner.

In other words the total value of your X coord & X Box Resolution values added together must equal or be below the Image Resolution X value, the same goes for the Y coord. 

If you are stuck click the To Top Right button and it will show you the max coord values you can input given the current box resolution.

(Whew lots of words)


Dev Integration:

It is a generic class that works a little similarly to how my XmlReader works. 

First initialise it by passing through the path to your game's character portraits directory. E.g: ".../GameDir/StreamingAssets/Portraits"

(Make sure to keep a reference to the initialised PortraitReader as they are instance based systems, meaning they work on a per instance basis).

Then when you need to generate a character image, call the GetPortrait method and pass through the Race and Gender directory names alongside the trait codes. The system will create a tierlist of all the images located within that given directory location and give you a randomized selection of the best available images.

(tldr: Tell it where to look and get a mostly if not exactly accurate image back.)

You will get a PortraitData struct that stores the image, it's folder path, and the Rect coordinates for the close-up. (There is a function that will generate the close-up sprite for you so don't worry about that.)

That's it. Character portrait integration complete. Enjoy!

Leave questions in the sticky post and I will do my best to help :)

Files

PortraitReader.cs 5 kB
Apr 10, 2022
portrait-renamer-win.zip 25 MB
Version 2 Apr 10, 2022

Get Portrait Renamer - Unity

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

To preemptively answer a question that may come up.
The trait codes I'm referring to are the same codes that exist in the .txt document that users would use to rename images. 

tldr: trait codes == option codes.