- Home /
How to make contructors for a javascript plugin?
I'm having problems testing constructors for plugins made in javascript.
var a = new TestObj();
works fine, but how do I assign arguments, and make alternative constructors? function TestObj(myString : String)
inside TestObj.js in the pluginsfolder doesn't seem to do the job. That's trying : var a = new TestObj("Hello World");
have you actually declared a class body in your javascript file? (Eg: class TestObj { ... }
Hey Duck.. Nope... THX ALOT.. I can see Eric had the same suspicion ;)=)
Answer by Eric5h5 · Mar 29, 2010 at 07:25 PM
class TestObj { var string : String;
function TestObj (myString : String) {
string = myString;
}
}
By the way, Javascript doesn't have plugins and you aren't gaining anything special by putting the script in a plugins folder. (Other than making it compile earlier, which can be done just as well by using the Standard Assets folder.)
THX alot.. Guess I'm messing up the concepts.. I'm using the two C# scripts in the plugin folder on the "procedurals" project as guide, and assumed they where plugins.. $$anonymous$$y bad as an apprentice ;)..
Your answer
Follow this Question
Related Questions
Calling inherited constructor 3 Answers
Loading Unity App from web page in iOS or Android 1 Answer
Making a List for Inventory System, Got an error in finding constructors and variables 1 Answer
WebGL build .jspre javascript plugin - how do I call functions from page? 1 Answer
Calling a function from another function in webgl plugin 0 Answers