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 john-essy · Nov 06, 2014 at 03:55 PM · c#

Access JS From C#

I have read up on this for most of the afternoon but i cannot for the life off me get it too work.

I am trying too access some scripts that are in JS from my main code base which is C#.

I have all of the JS files inside the plugins folder (Also tried Standard Assets) but i cannot even access the class to be able to access its methods or variables.

Inside the settings i have also changed the script compilation order for the 4 scripts i need to access and gave them a value representing something like this ----- > script 1 -200 script 2 -100 script 3 -80 script 4 -40.

I have no idea why it is not working can anyone help?

Thank you for taking the time to read this.

Cheers

John

Comment
Add comment · Show 3
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 Subzero619 · Nov 06, 2014 at 04:33 PM 0
Share

To access JS from C# you will need to put the C# in the standard assets folder not the JS.

avatar image john-essy · Nov 07, 2014 at 11:06 AM 0
Share

Hows that the case though when C# is compiled before JS?

avatar image john-essy · Nov 07, 2014 at 11:06 AM 0
Share

Also tried that and still no joy.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by orcunguducu · Nov 07, 2014 at 01:18 PM

Make sure your scripts are static or have a instance to access?

Comment
Add comment · Show 4 · 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 john-essy · Nov 07, 2014 at 06:12 PM 0
Share

Shit i never thought of that!

Testing now.

avatar image john-essy · Nov 07, 2014 at 06:12 PM 0
Share

Ah no there is an instance of them as they are on an object in my scene. :(

avatar image john-essy · Nov 10, 2014 at 02:42 PM 0
Share

Bump?.......

avatar image orcunguducu · Nov 10, 2014 at 02:55 PM 0
Share

It is not enough to be in scene to reach that script. You need an instance.

Can you try this:

 public class YourClassName: $$anonymous$$onoBehaviour 
  {   
      public static YourClassName Instance;
  
      void Awake() {
          Instance = this;
      }
 
      void HelloFunction() {
          //Bla bla
      }
  }
 
 
  public class AnotherClassName: $$anonymous$$onoBehaviour 
  {   
      void Start() {
          YourClassName.Instance.HelloFunction(); 
          //you are accessing YourClassName with static Instance
      }
  }



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

28 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 avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

js to C# - Instantiate(scoreParticle, object - Vector3(0,0,0.3), Quaternion.identity) 1 Answer

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

Lists, Arrays and c# equivilent of js Array() 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