Assign portrait created by player at runtime.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Dex
Posts: 5
Joined: Thu Jul 07, 2022 12:53 pm

Assign portrait created by player at runtime.

Post by Dex »

Hello! I'm creating a 2D game that features a character creator to allow the user to customize their character's portrait. The created portrait is a sprite renderer for the main body with other sprite renderers as children for the different body part options.
My intern is having some troubles recovering the portrait then assigning it at runtime to the Player portrait in the dialogue system. Could you point us in the right direction?
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assign portrait created by player at runtime.

Post by Tony Li »

Hi,

Here are two ways you can handle player-created multipart portraits:

1. Create the portrait in an area offscreen. Point a camera at it, and render that camera to a render texture. Then show the render texture. The Dialogue System Extras page has a RenderTexturePortrait Example that demonstrates how to do it with 3D models. The process is the same for sprite renderers.

2. Or make a subclass of StandardUISubtitlePanel for the player's subtitle panel. In this subclass, override the SetPortraitImage() method to compose your multipart player portrait.
Dex
Posts: 5
Joined: Thu Jul 07, 2022 12:53 pm

Re: Assign portrait created by player at runtime.

Post by Dex »

Thanks a lot, we'll try those :D
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Assign portrait created by player at runtime.

Post by Tony Li »

Glad to help! If you have questions on either one, let me know.
Post Reply