/** * <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); }
/** * <summary>Draws an icon at the Hotspot's centre.</summary> * <param name = "inWorldSpace">If True, the icon shall be drawn as a sprite in world space, as opposed to an OnGUI graphic in screen space.</param> */ public void DrawHotspotIcon(bool inWorldSpace = false) { if (iconAlpha > 0f) { if (!KickStarter.mainCamera.IsPointInCamera(GetIconScreenPosition())) { return; } if (inWorldSpace) { if (iconRenderer == null) { GameObject iconOb = new GameObject(this.name + " - icon"); iconRenderer = iconOb.AddComponent <SpriteRenderer>(); iconOb.transform.localScale = Vector3.one * (25f * KickStarter.settingsManager.hotspotIconSize); if (GameObject.Find("_Hotspots") && GameObject.Find("_Hotspots").transform.eulerAngles == Vector3.zero) { iconOb.transform.parent = GameObject.Find("_Hotspots").transform; } } if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon) { CursorIconBase icon = GetMainIcon(); if (icon != null) { iconRenderer.sprite = icon.GetSprite(); } } else { if (iconSprite == null && KickStarter.settingsManager.hotspotIconTexture != null) { iconSprite = UnityEngine.Sprite.Create(KickStarter.settingsManager.hotspotIconTexture, new Rect(0f, 0f, KickStarter.settingsManager.hotspotIconTexture.width, KickStarter.settingsManager.hotspotIconTexture.height), new Vector2(0.5f, 0.5f)); } if (iconSprite != iconRenderer.sprite) { iconRenderer.sprite = iconSprite; } } iconRenderer.transform.position = GetIconPosition(); iconRenderer.transform.LookAt(iconRenderer.transform.position + KickStarter.mainCamera.transform.rotation * Vector3.forward, KickStarter.mainCamera.transform.rotation * Vector3.up); } else { if (iconRenderer != null) { GameObject.Destroy(iconRenderer.gameObject); iconRenderer = null; } Color c = GUI.color; Color tempColor = c; c.a = iconAlpha; GUI.color = c; if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon) { CursorIconBase icon = GetMainIcon(); if (icon != null) { icon.Draw(GetIconScreenPosition()); } } else if (KickStarter.settingsManager.hotspotIconTexture != null) { GUI.DrawTexture(AdvGame.GUIBox(GetIconScreenPosition(), KickStarter.settingsManager.hotspotIconSize), KickStarter.settingsManager.hotspotIconTexture, ScaleMode.ScaleToFit, true, 0f); } GUI.color = tempColor; } } if (inWorldSpace && iconRenderer != null) { Color tempColor = iconRenderer.color; tempColor.a = iconAlpha; iconRenderer.color = tempColor; } }