- Home /
How to display EULA from Doc in Unity?
Hello everybody,
I've being trying to load a very long EULA file using Unity but I can not display it correctly. I have tried to change the file from doc to html but when I display the file, it shows html tags instead of format the text correctly. In addition the content is not display entire.
If anybody know how to display long text from file in Unity, I will be really appreciate if helps me
Thanks
Hello,
I have finally find how to load my file correctly . First of all, I converted the doc file to plane text due to it is not compatible with Unity (Compatible formats). After that I simply use ReadAllLines function from C#, which return an array of string, ins$$anonymous$$d of a single string (which can not manage the length of the file). Finally I just display this array with a for loop and GUILayout.
Code:
using UnityEngine;
using System.Collections;
public class LoadWordText : $$anonymous$$onoBehaviour {
public TextAsset EULA;
private Vector2 scrollPosition = Vector2.zero;
private string filename = "EULAtxt.txt";
private string[] lines;
// Use this for initialization
void Start () {
lines = System.IO.File.ReadAllLines (Application.dataPath + "/" + filename);
}
void OnGUI(){
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.$$anonymous$$axHeight(300), GUILayout.ExpandHeight (false));
for(int i=0; i < lines.Length; i++)
GUILayout.Label (lines[i], GUILayout.ExpandHeight (true));
GUILayout.EndScrollView();
}
}