I bet the problem is he doesn’t know how to substitute strings into the story text.
OK, here’s one approach. Define a little script that you will put on every input field, giving you a place to define which key (spot in the story) that field represents, and a convenient way to get the text that was entered:
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(InputField))]
public class EntryField : MonoBehaviour {
[Tooltip("Key to replace in the story with value from this field.")]
public string fieldName;
public string GetValue() {
return GetComponent<InputField>().text;
}
}
Attach this to your input field and then assign it a key, for example, maybe set fieldName to NAME. Now make a script that you attach to the story text, that creates the story by replacing fields in a template:
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class Story : MonoBehaviour {
[Tooltip("Put story text here, with string like #KEY defining key values.")]
[Multiline]
public string storyTemplate;
void Update() {
// for easier testing/debugging, let's just update our story every frame:
UpdateStory();
}
public void UpdateStory() {
// Start with our template.
string story = storyTemplate;
// Loop over all entry fields...
for each (var fld in FindObjectsOfType<EntryField>()) {
// Get the key (name) of this field, and its current value
string key = fld.fieldName;
string value = fld.GetValue();
// Substitute these into the story.
story = story.Replace("#" + key, value);
}
// Update our text.
GetComponent<Text>().text = story;
}
}
(This code is off the top of my head and untested, but should be approximately correct.)
So make a big multi-line Text in your UI (don’t worry about hiding it for now), attach this script to it, and set its storyTemplate to something like “Hello #NAME!”.
Then just run. As you change the name field (the one whose EntryField.fieldName property is “NAME”), you should see the story text update accordingly.
When you’re ready, you can delete the Update method in the Story script, and instead call UpdateStory from the button that hides the input panel and shows the story panel. Easy peasy at that point.