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 ik_jolan · Dec 03, 2013 at 07:46 PM · js-c#public strings

Use variabel in other script does not work

hello, I have a main script in c# where there is a public static string gameNumber; and a js script where I want to use this variabel I use this:

if (ConnectMenu.gameNumber == THREE){

then my code ending with } It used in a function spawn() now, every time I try to play it says

Unknown identifier: 'ConnectMenu'.

Does anybody can help me? I realy want this to work

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by belvita · Dec 03, 2013 at 10:50 PM

Try to convert ur java script code to c# code and access gamenumber variable from ur converted c# code.

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 flaviusxvii · Dec 03, 2013 at 11:09 PM 0
Share

I'm not judging. Just letting you know..

http://www.urbandictionary.com/define.php?term=ur

avatar image ik_jolan · Dec 04, 2013 at 09:10 AM 0
Share

The problem is, I can't change all of my codes to c#

It's to much work and my knowledge of c# is not that great

(ps flaviusxvii, I'm Belgian, English isn't that good)

avatar image flaviusxvii · Dec 04, 2013 at 03:05 PM 0
Share

I was talking to belvita.

avatar image ik_jolan · Dec 04, 2013 at 03:16 PM 0
Share

oh okay, never $$anonymous$$d

avatar image
0

Answer by EnglishMuffin123 · Dec 04, 2013 at 09:18 AM

Make sure your C# script with the variable you want to access is placed inside a folder called Plugins inside your assets folder.

Assets >> Plugins >> C# Script

Use getComponent() to access the script if it's on another GameObject.

getComponent Scripting Reference

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 ik_jolan · Dec 04, 2013 at 02:26 PM 0
Share

I can not replace it or I get an error Is that also possible in the directory: Assets>>FPS>>_Custom Assets>> scripts>> Networkc# ?

avatar image EnglishMuffin123 · Dec 04, 2013 at 11:23 PM 0
Share

What's your error? The problem with converting between c# and javascript is that accessing one language from the other is difficult. To access c# from js, the c# code must be in plugins. To access js from c#, the c# code must be in plugins.

avatar image ik_jolan · Dec 05, 2013 at 07:21 PM 0
Share

the eroor is about the cs script, other script use it on his current location if i remove it to Plugins most of them won't work and it as to much work to trace the scripts again

avatar image EnglishMuffin123 · Dec 05, 2013 at 11:59 PM 0
Share

Ok, if that's your problem then your only option is to rewrite the script in JavaScript or rewrite the script accessing it in C#. It's unfortunate but these languages are built differently so it's difficult to make them communicate.

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

19 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

Related Questions

how to convert string into numbers in C# 2 Answers

Error with converted Function? 0 Answers

Public variables wont display on inspector 0 Answers

Javascript to C#: Vector 3 rigidbody 1 Answer

Initiating the playback of a toggle through another onClick button 0 Answers


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