- Home /
Accessing functions on external JS in the same object
I've seen some questions regarding this but I wasn't able to make it work in a smooth way.
I've seen recommendations to add an external script into, for example, Script A by doing this:
var subScript : ScriptB;
Still, when I get to the inspector to select Script B i'm not able to select it (and i don't know why).
Anyway , i've resolved this by using
gameObject.Find("Object").GetComponent(ScriptB)
I don't have a problem with that as long as I have to reference an script that is enabled in an external object. But right now i have, let's call it OBJECT A.
Inside Object A I've added both components, Script A and Script B.
I have to call a function that's in Script B from Script A. It just doesn't make sense to find "myself" with :
gameObject.Find("ObjectA").GetComponent(ScriptB)
Since I'm ObjectA...
Is there any workaround this?
Thanks
That's no problem. The problem is that i'm invoking a function to find ObjectA and i'm executing the script INSIDE objectA. It looks redundant to me.