Hi guys,
I want to change Actor portrait from script:
string actorName = "Hero";
Sprite newPortrait = AvaStandard;
Actor actor = DialogueManager.MasterDatabase.GetActor(actorName);
if (actor != null)
{
//actor.Name = _saveLoadService.CurrentSave.HeroStats.Character.Name;
DialogueLua.SetActorField(actorName, "Display Name", name);
actor.AssignPortraitSprite(newPortrait);
}
And get this error:
Assets/24/Global/Scripts/Hero/HeroController.cs(70,40): error CS1503: Argument 1: cannot convert from 'UnityEngine.Sprite' to 'PixelCrushers.DialogueSystem.Actor.AssignSpriteDelegate'
Any advice?
Change Actor Portrait from script
Re: Change Actor Portrait from script
Hi,
Actor.AssignPortraitSprite() has a different purpose.
Just assign Actor.spritePortrait:
Note: If the Dialogue Manager's Other Settings > Instantiate Database is UNticked, this will change your dialogue database asset when in play mode. If Instantiate Database is unticked, instead add a Dialogue Actor component to the actor's GameObject. Set the actor and spritePortrait. Example:
Actor.AssignPortraitSprite() has a different purpose.
Just assign Actor.spritePortrait:
Code: Select all
actor.spritePortrait= newPortrait;
Code: Select all
dialogueActor.actor = actor.Name;
dialogueActor.spritePortrait = newPortrait;
-
- Posts: 13
- Joined: Fri Sep 22, 2023 7:35 pm
Re: Change Actor Portrait from script
error CS0103: The name 'dialogueActor' does not exist in the current context
What should I use additionally to using PixelCrushers.DialogueSystem;?
What should I use additionally to using PixelCrushers.DialogueSystem;?
Re: Change Actor Portrait from script
Hi,
That code assumes that you've added a Dialogue Actor component to the GameObject, and that 'dialogueActor' is a reference to that component, such as: var dialogueActor = yourGameObject.GetComponent<DialogueActor>();
What about just using actor.spritePortrait = newPortrait? This doesn't require a Dialogue Actor component. Can you do that, or did you untick the Dialogue Manager's Instantiate Database checkbox?
That code assumes that you've added a Dialogue Actor component to the GameObject, and that 'dialogueActor' is a reference to that component, such as: var dialogueActor = yourGameObject.GetComponent<DialogueActor>();
What about just using actor.spritePortrait = newPortrait? This doesn't require a Dialogue Actor component. Can you do that, or did you untick the Dialogue Manager's Instantiate Database checkbox?
-
- Posts: 13
- Joined: Fri Sep 22, 2023 7:35 pm
Re: Change Actor Portrait from script
Thanks - it helped!Tony Li wrote: ↑Sat Sep 23, 2023 2:51 pm Hi,
That code assumes that you've added a Dialogue Actor component to the GameObject, and that 'dialogueActor' is a reference to that component, such as: var dialogueActor = yourGameObject.GetComponent<DialogueActor>();
What about just using actor.spritePortrait = newPortrait? This doesn't require a Dialogue Actor component. Can you do that, or did you untick the Dialogue Manager's Instantiate Database checkbox?
Re: Change Actor Portrait from script
Glad to help!