I'm attempting to create a StringTableMgr class that will load and keep track of string tables, but since it has to be globally accessible, I'm looking at this:
to see how to create a script that can be globally accessed without having to have an instance in each game object.
My problem is that when I do it in the same way as the article I get a "You are not allowed to call Internal_CreateGameObject when declaring a variable" error.
I get the error on the line at the top where I create the GameObject. If I leave the creation code, and reference the 'm_StringTableMgr' var directly, I get an null reference exception on the 'foreach' statement in LoadStringTable, which could be either the StringTableMgr var or the 'm_StringTableList'
I don't know what I'm doing wrong, since I'm fairly certain if this code were to run, it would work, since by calling GetInstance() in the Awake() function, I'm basically assuring the creation of the StringTableMgr object and it's data structures.
Can anyone see anything that I've missed, or think of something that I should know but don't?
asked Apr 30 '11 at 10:22 AM
Since you're creating this in script anyway, just remove the ": MonoBehaviour" from the class -- make it a regular class, not a component.
answered May 01 '11 at 12:49 AM