public override void PreDisplay(int _slot, int languageNumber, bool isActive) { switch (graphicType) { case AC_GraphicType.DialoguePortrait: if (portraitCharacterOverride) { localTexture = portraitCharacterOverride.GetPortrait().texture; speechIsAnimating = portraitCharacterOverride.GetPortrait().isAnimated; } else { UpdateSpeechLink(); if (speech != null) { localTexture = speech.GetPortrait(); speechIsAnimating = speech.IsAnimating(); } } break; case AC_GraphicType.DocumentTexture: if (Application.isPlaying && KickStarter.runtimeDocuments.ActiveDocument != null) { if (localTexture != KickStarter.runtimeDocuments.ActiveDocument.texture) { if (KickStarter.runtimeDocuments.ActiveDocument.texture) { Texture2D docTex = KickStarter.runtimeDocuments.ActiveDocument.texture; sprite = UnityEngine.Sprite.Create(docTex, new Rect(0f, 0f, docTex.width, docTex.height), new Vector2(0.5f, 0.5f)); } else { sprite = null; } } localTexture = KickStarter.runtimeDocuments.ActiveDocument.texture; } break; case AC_GraphicType.ObjectiveTexture: if (Application.isPlaying && KickStarter.runtimeObjectives.SelectedObjective != null) { if (localTexture != KickStarter.runtimeObjectives.SelectedObjective.Objective.texture && KickStarter.runtimeObjectives.SelectedObjective.Objective.texture) { Texture2D objTex = KickStarter.runtimeObjectives.SelectedObjective.Objective.texture; sprite = UnityEngine.Sprite.Create(objTex, new Rect(0f, 0f, objTex.width, objTex.height), new Vector2(0.5f, 0.5f)); } localTexture = KickStarter.runtimeObjectives.SelectedObjective.Objective.texture; } break; default: break; } SetUIGraphic(); }
/** * <summary>Gets a Sprite based on the portrait graphic of the speaking character. * If lipsincing is enabled, the sprite will be based on the current phoneme.</summary> * <returns>The speaking character's portrait sprite</returns> */ public UnityEngine.Sprite GetPortraitSprite() { if (speaker != null) { CursorIconBase portraitIcon = speaker.GetPortrait(); if (portraitIcon != null && portraitIcon.texture != null) { if (IsAnimating()) { if (speaker.isLipSyncing) { return(portraitIcon.GetAnimatedSprite(speaker.GetLipSyncFrame())); } else { portraitIcon.GetAnimatedRect(); return(portraitIcon.GetAnimatedSprite(true)); } } else { return(portraitIcon.GetSprite()); } } } return(null); }