- Home /
Bought an asset that uses C#, I'm a UnityScript guy
I know, "learn both languages," "stick to one language per project," etc. I bought a nice shader package that, so far, does everything I need it to. I just struggle making all my JS scripts play nicely with the author's C# script. He has a boolean "DrawOutline" in his script, which I need to be able to turn on and off in one of my JS scripts. I've got them in the right folders so that there aren't any missing namespace errors, but when I try this:
var outlineGlowRenderer = gameObject.GetComponent(OutlineGlowRenderer);
... I get a null reference exception, and the script can't be accessed. I also tried a few different variations of this, including removing "gameObject," adding .DrawOutline after the GetComponent(), etc, and still just null refs. I suspect it's some kind of JS/C# mess, which would be unfortunate, but getting this to work would conclude one of the biggest hurdles in this project so far. Any help would be awesome!!
What is the filename for the C# file? Also, is the code for the C# in a namespace format?
The file is called OutlineGlowRenderer.cs, and from what I can tell it's not in a namespace format; at least the word "namespace" doesn't appear at any point in the script.
Answer by StewVanB · Jun 14, 2014 at 07:22 AM
Make sure that your OutlineGlowRenderer.cs is in the Standard Assets folder and that your .js files are in another folder not in Standard Assets. Then, In your .js file when you want an instance of the OutlineGlowRenderer use this:
var outlineRenderer : OutlineGlowRenderer = gameObject.GetComponent(OutlineGlowRenderer);
outlineRenderer.DrawOutline();
Answer by NggingCrew · Jun 14, 2014 at 06:38 AM
if you're going to call the JS script using C #, first put your js script to Standard Asset Folder
Nah, I'm using a JS script to call C# script, so my C# script is in the Standard Asset Folder.
Yea, place C# script to Standart Asset when JS script call C# script.
Your answer
![](https://koobas.hobune.stream/wayback/20220613151509im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Attach script twice. 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
NullRefenceException error 1 Answer
NullReferenceException for reasons I don't understand. 1 Answer