As I can assign a script to an object using JavaScript?

As I can assign a script to an object using JavaScript?

I have a script called "MyScript". And i have an object called "MyCube".

I want to assign the script to the object in javascript

thanks

you mean: "How can I assign a script to an object using javascript".

2 Answers

2

this is one computational intensive way:

GameObject.Find("MyCube").AddComponent("MyScript");

Just drag a drop the script to your game object.

Did you ever figure this out? Getting the same exact behavior... reverting does nothing, and dragging it fresh doesn't either! Seems permanently broken :/