0

I have C# scripts in my Unity project. I want to use it in my JS script. But I can't make any reference to a class in the C# script.

How to do that?

1
  • The correct tag for Unity is [unity3d]. Please make sure to use this tag. If you don't most of us might miss your question. Commented Jan 13, 2014 at 9:33

1 Answer 1

1

The problem here is that at compile time different compilers are used for the different languages. So they have no knowledge of each other's existence. There is a way around it by considering the steps in which Unity compiles code.

Code in a folder named Plugins for example (as well as Standard Assets" and "Pro Standard Assets") is compiled before code in regular folders. So if you want to call your C# code using UnityScript, put your C# code in a folder name Plugins within your assets.

If you then keep your UnityScript code in a regular folder, once it will be compiled the C# code should already be compiled and available.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.