Browse Source

Portrait 2019 fix (#743)

Use overrideSprite instead of sprite on UIImages
master
Steve Halliwell 5 years ago committed by GitHub
parent
commit
c0667c824f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      Assets/Fungus/Scripts/Components/PortraitController.cs
  2. 2
      Assets/Fungus/Scripts/Components/SayDialog.cs

10
Assets/Fungus/Scripts/Components/PortraitController.cs

@ -196,7 +196,7 @@ namespace Fungus
// Configure the portrait image
Image portraitImage = portraitObj.GetComponent<Image>();
portraitImage.preserveAspect = true;
portraitImage.sprite = character.ProfileSprite;
portraitImage.overrideSprite = character.ProfileSprite;
portraitImage.color = new Color(1f, 1f, 1f, 0f);
// LeanTween doesn't handle 0 duration properly
@ -455,7 +455,7 @@ namespace Fungus
float duration = (options.fadeDuration > 0f) ? options.fadeDuration : float.Epsilon;
// Fade out a duplicate of the existing portrait image
if (options.character.State.portraitImage != null && options.character.State.portraitImage.sprite != null)
if (options.character.State.portraitImage != null && options.character.State.portraitImage.overrideSprite != null)
{
GameObject tempGO = GameObject.Instantiate(options.character.State.portraitImage.gameObject);
tempGO.transform.SetParent(options.character.State.portraitImage.transform, false);
@ -463,7 +463,7 @@ namespace Fungus
tempGO.transform.localScale = options.character.State.position.localScale;
Image tempImage = tempGO.GetComponent<Image>();
tempImage.sprite = options.character.State.portraitImage.sprite;
tempImage.overrideSprite = options.character.State.portraitImage.overrideSprite;
tempImage.preserveAspect = true;
tempImage.color = options.character.State.portraitImage.color;
@ -473,10 +473,10 @@ namespace Fungus
}
// Fade in the new sprite image
if (options.character.State.portraitImage.sprite != options.portrait ||
if (options.character.State.portraitImage.overrideSprite != options.portrait ||
options.character.State.portraitImage.color.a < 1f)
{
options.character.State.portraitImage.sprite = options.portrait;
options.character.State.portraitImage.overrideSprite = options.portrait;
options.character.State.portraitImage.color = new Color(1f, 1f, 1f, 0f);
LeanTween.alpha(options.character.State.portraitImage.rectTransform, 1f, duration).setEase(stage.FadeEaseType).setRecursive(false);
}

2
Assets/Fungus/Scripts/Components/SayDialog.cs

@ -394,7 +394,7 @@ namespace Fungus
if (image != null)
{
characterImage.sprite = image;
characterImage.overrideSprite = image;
characterImage.gameObject.SetActive(true);
currentCharacterImage = image;
}

Loading…
Cancel
Save