Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by growling_egg · Jun 14, 2014 at 05:19 AM · c#javascriptnullreferenceexception

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!!

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image StewVanB · Jun 14, 2014 at 06:30 AM 0
Share

What is the filename for the C# file? Also, is the code for the C# in a namespace format?

avatar image growling_egg · Jun 14, 2014 at 06:43 AM 0
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

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();
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image growling_egg · Jun 14, 2014 at 06:41 AM 0
Share

Nah, I'm using a JS script to call C# script, so my C# script is in the Standard Asset Folder.

avatar image NggingCrew · Jun 14, 2014 at 06:59 AM 0
Share

Yea, place C# script to Standart Asset when JS script call C# script.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges