How to change the Actor's Portrait with c# codes?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Deadlybrunch
Posts: 6
Joined: Mon Jul 06, 2020 11:15 am

How to change the Actor's Portrait with c# codes?

Post by Deadlybrunch »

Hi,
Sorry to ask the stupid question. I've checked the docs about "SetPortrait()", but i dont find a definitely way to show me how to do that with a c# script.
In the docs there is a method: "static void PixelCrushers.DialogueSystem.DialogueManager.SetPortrait(string actorName, string portraitName)". And in the interpretation, it tells me that i can "Sets an actor's portrait by the name of a texture in a Resources folder". But when i typing the code, an error occured.
For example:
My actor's name is "Enemy".
And the portrait path is "Resources/Prefabs/Textures/HeadPhoto4".
Is there anything wrong with the code " PixelCrushers.DialogueSystem.DialogueSystemController.SetPortrait("Enemy", "Resources/Prefabs/Textures/HeadPhoto4"); " ?
Or is there any references about this?
Thanks for your help!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change the Actor's Portrait with c# codes?

Post by Tony Li »

Hi,

Here's the API info: DialogueManager.SetPortrait

Change your code to:

Code: Select all

PixelCrushers.DialogueManager.SetPortrait("Enemy", "Prefabs/Textures/HeadPhoto4");
Deadlybrunch
Posts: 6
Joined: Mon Jul 06, 2020 11:15 am

Re: How to change the Actor's Portrait with c# codes?

Post by Deadlybrunch »

Got it, thank you very much!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to change the Actor's Portrait with c# codes?

Post by Tony Li »

Glad to help!
Post Reply