O'Reilly logo

Mastering Unity Scripting by Alan Thorn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Text Assets – loading from the local files

Another method to load in text data is externally from the project, that is, from files on the local hard drive. Text Data loaded in this way is read into the project dynamically from script, not necessarily at scene startup, but whenever you execute the necessary code. This means that for longer text files that involve heavy processing, lag becomes a serious consideration. In general, therefore, it is best to prefer statically loaded Text Assets to dynamic forms. For any dynamic assets, I recommend that you load and process them at scene startup to avoid in-game lagging, as shown in the following code sample 6-26:

 using UnityEngine;
 using System.Collections;
 using System.IO; //Function to load text ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required