Spencer Michaels
Spencer Michaels

Reputation: 25

Unity Calling C# function from UnityScript file

I'm trying to run a function in C# from UnityScript. My UnityScript file has:

GetComponent("C#File").C#FunctionName();

But in the editor it's telling me that the function isn't a member of UnityEngine.Component.

Upvotes: 1

Views: 55

Answers (2)

Mughees Mehdi
Mughees Mehdi

Reputation: 71

Try

 GetComponent<"C#File">().C#FunctionName();

Upvotes: 1

Yotam Salmon
Yotam Salmon

Reputation: 2411

You need to put the "to be accessed" script in one of the folders thats compiled earlier. That does not only mean the editor folder, but also Plugins, Standard Assets and Pro Assets

That way scripts of the other languages are able to work with it.

The only alternative is not to access it directly at all and use SendMessage instead

The least amount of trouble and headache is present if you just focus on one language instead of mixing 2+ languages

Upvotes: 0

Related Questions