Browse Source

Limit Characters Shown In NarrativeLog to Avoid 65000 Vertices Limit

Remove hardcoded stuffs

Change to static type
master
breadnone 4 years ago committed by Steve Halliwell
parent
commit
6a0f06b47e
  1. 7
      Assets/Fungus/Scripts/Components/NarrativeLog.cs
  2. 4
      Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs

7
Assets/Fungus/Scripts/Components/NarrativeLog.cs

@ -35,6 +35,7 @@ namespace Fungus
/// </summary> /// </summary>
public static event NarrativeAddedHandler OnNarrativeAdded; public static event NarrativeAddedHandler OnNarrativeAdded;
public delegate void NarrativeAddedHandler(NarrativeLogEntry data); public delegate void NarrativeAddedHandler(NarrativeLogEntry data);
public static int maxSize {get; set;} = 10000;
public static void DoNarrativeAdded(NarrativeLogEntry data) public static void DoNarrativeAdded(NarrativeLogEntry data)
{ {
if (OnNarrativeAdded != null) if (OnNarrativeAdded != null)
@ -140,6 +141,12 @@ namespace Fungus
output += "<b>" + history.entries[i].name + "</b>\n"; output += "<b>" + history.entries[i].name + "</b>\n";
output += history.entries[i].text + "\n\n"; output += history.entries[i].text + "\n\n";
} }
if (output.Length > maxSize)
{
output = "... " + output.Substring(output.Length - maxSize, maxSize);
}
return output; return output;
} }

4
Assets/Fungus/Scripts/Components/NarrativeLogMenu.cs

@ -26,6 +26,9 @@ namespace Fungus
[Tooltip("A scrollable text field used for displaying conversation history.")] [Tooltip("A scrollable text field used for displaying conversation history.")]
[SerializeField] protected ScrollRect narrativeLogView; [SerializeField] protected ScrollRect narrativeLogView;
[Tooltip("Limit characters to be shown in Narrative Log")]
[SerializeField] protected int maxCharacters = 10000;
protected TextAdapter narLogViewtextAdapter = new TextAdapter(); protected TextAdapter narLogViewtextAdapter = new TextAdapter();
[Tooltip("The CanvasGroup containing the save menu buttons")] [Tooltip("The CanvasGroup containing the save menu buttons")]
@ -132,6 +135,7 @@ namespace Fungus
{ {
if (narrativeLogView.enabled) if (narrativeLogView.enabled)
{ {
NarrativeLog.maxSize = maxCharacters;
narLogViewtextAdapter.Text = FungusManager.Instance.NarrativeLog.GetPrettyHistory(); narLogViewtextAdapter.Text = FungusManager.Instance.NarrativeLog.GetPrettyHistory();
Canvas.ForceUpdateCanvases(); Canvas.ForceUpdateCanvases();

Loading…
Cancel
Save