private Texture2D GetPortraitByActorName(string actorName) { // Also suppress logging for Lua return Actor[].Current_Portrait. var originalDebugLevel = DialogueDebug.Level; DialogueDebug.Level = DialogueDebug.DebugLevel.Warning; string textureName = DialogueLua.GetActorField(actorName, "Current Portrait").AsString; DialogueDebug.Level = originalDebugLevel; if (string.IsNullOrEmpty(textureName)) { return(null); } else if (textureName.StartsWith("pic=")) { Actor actor = database.GetActor(actorName); if (actor == null) { return(null); } else { return(actor.GetPortraitTexture(Tools.StringToInt(textureName.Substring("pic=".Length)))); } } else { return(DialogueManager.LoadAsset(textureName) as Texture2D); } }
private Sprite GetPortraitByActorName(string actorName, Actor actor) { // Also suppress logging for Lua return Actor[].Current_Portrait. var originalDebugLevel = DialogueDebug.level; DialogueDebug.level = DialogueDebug.DebugLevel.Warning; string imageName = DialogueLua.GetActorField(actorName, DialogueSystemFields.CurrentPortrait).asString; DialogueDebug.level = originalDebugLevel; if (string.IsNullOrEmpty(imageName)) { return((actor != null) ? actor.GetPortraitSprite(): null); } else if (imageName.StartsWith("pic=")) { if (actor == null) { return(null); } else { return(actor.GetPortraitSprite(Tools.StringToInt(imageName.Substring("pic=".Length)))); } } else { return(UITools.CreateSprite(DialogueManager.LoadAsset(imageName) as Texture2D)); } }
/// <summary> /// Returns the actor's current portrait sprite. /// </summary> public Sprite GetPortraitSprite() { //--- Was: return UITools.GetSprite(portrait, spritePortrait); //--- Instead, check for override set by SetPortrait(): var originalDebugLevel = DialogueDebug.level; // Suppress logging for Lua return Actor[].Current_Portrait. DialogueDebug.level = DialogueDebug.DebugLevel.Warning; string imageName = DialogueLua.GetActorField(Name, DialogueSystemFields.CurrentPortrait).asString; DialogueDebug.level = originalDebugLevel; if (string.IsNullOrEmpty(imageName)) { return(GetPortraitSprite(1)); } else if (imageName.StartsWith("pic=")) { return(GetPortraitSprite(Tools.StringToInt(imageName.Substring("pic=".Length)))); } else { var sprite = GetPortraitSprite(imageName); return((sprite != null) ? sprite : UITools.CreateSprite(DialogueManager.LoadAsset(imageName) as Texture2D)); } }
public void AssignPortraitSprite(AssignSpriteDelegate assignSprite) { var originalDebugLevel = DialogueDebug.level; // Suppress logging for Lua return Actor[].Current_Portrait. DialogueDebug.level = DialogueDebug.DebugLevel.Warning; string imageName = DialogueLua.GetActorField(Name, DialogueSystemFields.CurrentPortrait).asString; DialogueDebug.level = originalDebugLevel; if (string.IsNullOrEmpty(imageName)) { assignSprite(GetPortraitSprite(1)); } else if (imageName.StartsWith("pic=")) { assignSprite(GetPortraitSprite(Tools.StringToInt(imageName.Substring("pic=".Length)))); } else { DialogueManager.LoadAsset(imageName, typeof(Texture2D), (asset) => { assignSprite(UITools.CreateSprite(asset as Texture2D)); }); } }