Character portrait sprite reference
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Character portrait sprite reference
Hey there, I am wondering - is there a way to get a reference to an actor's portrait sprite in code? I'd like to get a reference to the sprite so I can use it to populate some dynamic UI. I figure I should be able to ask the dialogue system for this since it's storing everything and I'd rather not create another way to get the sprites. Thank you!
Re: Character portrait sprite reference
Hi,
If you're talking about the current image being used in a conversation, there are a few ways. You can use an OnConversationLine(Subtitle) method on the Dialogue Manager or either primary participant:
Alternatively, if a conversation is active, you can check DialogueManager.currentConversationState.subtitle:
Or you can check the subtitle panel directly:
---
If you just want to get the portrait image(s) of any actor at any time, get the Actor from the DialogueManager.masterDatabase:
If you're talking about the current image being used in a conversation, there are a few ways. You can use an OnConversationLine(Subtitle) method on the Dialogue Manager or either primary participant:
Code: Select all
public void OnConversationLine(Subtitle subtitle)
{
Debug.Log("Dialogue Text is: " + subtitle.formattedText.text);
Debug.Log("Speaker's portrait is: " + subtitle.GetSpeakerPortrait());
}
Code: Select all
if (DialogueManager.isConversationActive)
{
Debug.Log("Speaker's portrait is: " + DialogueManager.currentConversationState.subtitle.GetSpeakerPortrait());
}
Code: Select all
Debug.Log("Speaker's portrait is: " + DialogueManager.standardUISubtitlePanel.conversationUIElements.
defaultNPCSubtitlePanel.portraitImage.sprite);
If you just want to get the portrait image(s) of any actor at any time, get the Actor from the DialogueManager.masterDatabase:
Code: Select all
Actor fred = DialogueManager.masterDatabase.GetActor("fred");
Debug.Log("Fred's main portrait is: " + fred.spritePortrait);
Debug.Log("# of alternate portraits: " + fred.spritePortraits.Count);
-
- Posts: 97
- Joined: Thu Aug 12, 2021 6:39 pm
Re: Character portrait sprite reference
Awesome, got it! Thank you.
Re: Character portrait sprite reference
Glad to help!