When they choose a sprite from the list, use these two methods to set the player's portrait:
Code: Select all
DialogueLua.SetActorField(actorName, DialogueSystemFields.CurrentPortrait, sprite.name);
DialogueManager.instance.SetActorPortraitSprite(actorName, sprite);
Alternatively, you can let the player choose from the list of portrait sprites assigned to the Player actor in the Dialogue Editor. In this case, use:
Code: Select all
var sprite = playerActor.GetPortraitSprite(picNumber);
DialogueLua.SetActorField(actorName, DialogueSystemFields.CurrentPortrait, $"pic={picNumber}");
DialogueManager.instance.SetActorPortraitSprite(actorName, sprite);
If you want to allow players to provide their own images, loading images at runtime is outside the scope of the Dialogue System. Briefly: You'll need to load the bytes of the image into a byte[] array, create a new Texture2D object, and then call Texture2D.LoadImage() to load the bytes of the image into your new Texture2D. From there, you can use Sprite.Create() to create a Sprite object from the Texture2D.
Then you can assign the Sprite object to the actor's spritePortrait property, such as:
Code: Select all
var actor = DialogueManager.masterDatabase.GetActor("Player");
actor.spritePortrait = YourSprite;