- Home /
Question by
CoreCapator · Apr 24, 2013 at 02:26 PM ·
errortextassetload
Script to load a text file gives error.
The following script will not load in unity, giving out this error:
BCE0023: No appropriate version of 'UnityEngine.GUILayout.Label' for the argument list '(UnityEngine.TextAsset)' was found.
Here's the script:
#pragma strict
var scrollViewVector : Vector2 = Vector2.zero;
var TextToDisplay : TextAsset;
function OnGUI () {
scrollViewVector = GUI.BeginScrollView (Rect (25, 25, 100, 100), scrollViewVector, Rect (0, 0, 400, 400));
GUILayout.Label(TextToDisplay);
GUI.EndScrollView();
}
The script is supposed to load a *.txt file. Any advice on what I'm doing wrong is welcome.
Comment
Best Answer
Answer by CHPedersen · Apr 24, 2013 at 02:31 PM
This fails because, like the compiler says, there is no version of the GUI Label that accepts a TextAsset as its argument. Instead, you need to pass it the string contained within the asset, i.e. TextAsset.text:
GUILayout.Label(TextToDisplay.text);