JS Typecasting when the resulting script can vary

I have a bit of a stumper for strict typecasting. In base Unity this works as the type is not relevant. I have a controller script and an advanced version that inherits it. BasicScript is on most objects, but Advanced is needed for a few objects.

I have a function that gets the script on the object using GetComponent. If one is missing it tries for the other. So if there is no direct basic script, it looks for advanced and returns it.

In declaring explicitly, I end up with it forcing all of them to “BasicScript” even though some should be AdvancedScript". Is there any reasonable way to have a variable in the iPhone setup that can get more than one type of object/script? The strict declaration is killing the code. If it would run as is it would work fine, but I keep getting “funcitonName” is not a member of type “Object”, or I get Null if I explicitly set the type.

Ideas?

Thanks.

-Chuck

I haven’t studied them yet (I’m about to start experimenting), but it might be worth looking into creating an Interface.

Than again it might not. Like I said, I’m not really familiar with them yet.

I would like to help.

Can you post an example of your code??

I played a bit with it yesterday and it seems to suddenly work. I have a feeling I had an error in possibly setting an explicit return value from the function. It now seems to accept either the basic or advanced script as a valid instance of “basic”. I don’t think it would cause an actual run time problem if it would compile, but Unity was not letting it get past that point without a declaration.

I did find that to get it to work I had to put a dummy function in basic for any called functions in basic so that it didn’t give the “method not found in object” alert.

Thanks.