**Hi Guys, I have a mistake "slicing" an class variable. For better understanding I created a test file, trying to help you guys figuring out that problem.**
Code explanation:
There are two classes which are containing the key lorem_ipsum. These classes are assigned to the variables "test" & "aTest" And as you can see these two variables also do have the key lorem_ipsum with some test text as content. Then there is a for-loop which contains the string, all variables are written in. The array splits this text string after a "," What we have now is array[0] = test & array[1] = aTest. Then we should log the lorem_ipsum key from these two variables we found in the textString and split it in two tiles. And there is the error. "*BCE0048: Type 'ScriptFileName' does not support slicing*" In my case the script was called Inventory so the error was "*Assets/Scripts/Inventory.js(94,15): BCE0048: Type 'Inventory' does not support slicing.*" The cause why I did this like this was that the String Content was used to call the variable by its name. (Worked fine on the website jsbin.com) So I don't know how to fix that errors, I hope you guys do.
If you don't really understand what I tried to explain you, feel free to ask me some more details.
Code:
public class ThisIsATest() {
public var lorem_ipsum : String;
}
public class ThisIsAnotherTest() {
public var lorem_ipsum : String;
}
function Start() {
var test = ThisIsATest();
var aTest = ThisIsAnotherTest();
test.lorem_ipsum = "Lorem ipsum dolor and so on";
aTest.lorem_ipsum = "Another text";
for (var i = 0; i < array.length; i++) {
var textString = "test,aTest";
array = textString.split(',' [0]);
Debug.Log(this[this.array.lorem_ipsum]);
}
}
↧