instantiate a script that is not attached to a GO?

Anyone know if there is a way to instantiate a script that is not attached to a game object? I'm used to working in Director where I can create instances of any script on the fly and I'm trying to find a comparable Unity technique.

Specifically, I want to create a wrapper for the WWW class so I can instantiate multiple objects to do web operations and have them call back when they are complete. The reason for this is I want to have several www operations going on at the same time and the 'yield' part is getting confusing.

try the Scriptable Object class.


thanks - I’ve started digging around in that but it’s still not working. I am trying to instantiate an object and then call some functions in it:

w = ScriptableObject.CreateInstance("rp WWW class");
 		w.SetCallback(gameObject, "webOpComplete", www_array.length);

I get errors that "“the script class needs to derive from a ScriptableObject” along with “SetCallabck is not a member of UNityEngine.ScriptableObject”

Am I even close with my usage or should I go back to 0?


Quoting myself… how pathetic is that! :sweat_smile:

I’m still trying to make my way with using the ‘ScriptableObject’ function. Still getting the errors mentioned above. What I am trying to do is create instances of a script, call some functions on the instances, set some callbacks, and then store the instance in an array until the callback is called.

I’m used to working in this style in Director and trying to come up with an equivalent (or equal/better) method in Unity. The reason for the callback method is that it allows the instances to do their tasks without having to monitor them.

Can someone tech out the issue with my use of ‘ScriptableObject’?



See my post in your other thread on an approach that might work for you.