Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 djkr · Aug 24, 2011 at 04:23 AM · c#javascriptmysql

How to Pass a static var in Javascript value into a c# or download mysql text data using c#

Question :

I'm looking to either: How to Pass a static var in Javascript value into a c# or download mysql text data using c#?

ORIGINALLY I WAS TRYING TO DO THIS:

If I simply want to take the value inside of a STATIC VAR XX (where XX is my variable (will be full of Paragraphs of text) IN A JAVASCRIPT - and then Use a C# SCRIPT to Dsiplay that variable, How do I do that? Again - just trying to assign a JavaScripts Variable (for example 'XX') and transfer that value over to a CS Script - how would the C-Sharp script look?

Another way would be to simply download text from the MySQL Database (Its texts with "~" as spaces (they need to be stripped out before displaying. Then put the text into an existing variable so assign a string ...example: rowLabel = (value from the Javascript or Web). [I am using/updating the free script "GUITouchScroll.cs".]

Your help would be Greatly appreciated! Thanks! DJKR

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

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Joshua · Aug 24, 2011 at 05:16 AM

The problem you cannot simply reference any variable from a script written in JS from a script in C# is because both languages are compiled at the same time. So when you 'reference' something in an other language the compiler doesn't know about what you're referencing yet and will throw an error. So the problem is compilation order.

If you've clicked that link you basically already know what to do. Put the JS script you want to reference in a folder called "Standard Assets" or "Plugins" in the root of your project. Then you can simply reference it from any script in any language, so for instance from C# it would be:

 string messageToAccess = NameOfTheJSScript.nameOfTheStaticVariable;



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 djkr · Aug 24, 2011 at 06:14 AM

This is awesome... Thanks for your help!! I will try this and post any updates or issues.

Cheers! :) DJKR,This is awesome... I will try it, and let you know...

Thank-You Soooooooo Much!! :) DJKR

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 SrBilyon · Aug 24, 2011 at 09:00 AM

You could use SendMessage in your Javascript File. Not sure how efficient this is, or if the code below works as it... (5am programming)

Example:

In your JS:

 var livesCount : int = 3;
 
 function Update ()
 {
 SendMessage("GetLivesCount", livesCount)
 }

Now in your CS:

 private int livesCount;
  
 void GetLivesCount(int jsLivesCount)
 {
    livesCount = jsLivesCount;
 }
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 djkr · Aug 25, 2011 at 11:21 PM

Thanks, Been struggling with this, but still can't get it. Is there anyone who would accept pay to help resolve this? I need help fast. Please email me: djkr@djkr.fm ,Thanks, but still having problems (I'm a noob to c#)... I'll pay someone to help me. Please email me Djkr@Djkr.fm Cheers K

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 djkr · Sep 13, 2011 at 07:35 PM

Found the Solution:

Thanks for your replies!... I ended up creating a prefab in the Javascript - and converting it all over to use just Javascript... then I could drag and drop a prefab with the attached JavaScript into the (Required) Variable that had the Null.

Again, I appreciate your responses!

Cheers, Kris

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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Problem Javascript to C# 3 Answers

dealing with gameObject formations 1 Answer

Javascript equivalent of an inspector C# public List? 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