I have a script which needs to do two things:
(1) Detect the presence on another script in my project (2) If the other script exists, call a function in it
I need to do this to make two libraries I am releasing seperatley work with each other if they are both present in the same Unity project.
What would be the best way to accomplish this? So far I am playing with reflection, obscure OO ideas, eval inside a try/catch block, script 2 storing a function reference for itself inside a static variable of script 1, etc... I have a feeling I am, as usual, over thinking this.
asked Dec 18 '11 at 02:12 AM
Yep! I was overthinking it :) gameObject.AddComponent ("OtherLibrary"); worked perfectly. Thanks for your ideas!
answered Dec 18 '11 at 08:11 AM
I've never done anything like that, but since you asked, I tried this:
It seems to do what I believe you describe.
answered Dec 18 '11 at 02:34 AM