I’ll admit that I’m completely new to C# and Unity3D. I am coming from an ActionScript 3.0 background, where I can create a class file that can then be instantiated from within other classes, as in:
var foo:Bar = new Bar();
Normally, I’d write a class to handle specific tasks, like loading and parsing an XML file, and I’d be able to instantiate it where needed to perform its duty. I’m trying to do the same with a tiny XMLParser class that I found on the forums here.
My question, then, is: How do I use this? I can’t seem to just place it anywhere in the Project folder and instantiate it. Placing it in the Plugins folder or the Standard Assets folder makes no difference. I can’t place it on a GameObject because it doesn’t inherit from MonoBehavior, and I know that I could edit it to do so, but what’s the point? If the code was provided like this I’m assuming that they wrote it to work this way, and I just have no idea how to use it properly.
So. I want to write a utility class, as in:
using UnityEngine;
using System.Collections;
class XMLParser {
XMLParser() { }
Foo ParseString(string xmlString) {
// parse
Foo parsedXML = Bar;
return parsedXML;
}
}
Is there something I’m totally missing on how to do this? or is this just not how Unity3D works?