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
-1
Question by Ssiroo · Aug 07, 2014 at 06:22 PM · c#javascriptvariable

Acces C# via Unityscript

Hello, Is it possible to access a variable and change it if it's part of a C# script and Im using Unityscript.

For example. This is the c# script :

public string stringy = "Stringy string";

That's stored in scriptyscript.cs

Can I access it from an unityscript ?

Example :

 var varyvar : scriptyscript;
 
 function Start ()
 {
     varyvar = GameObject.Find("Player").GetComponent(ScriptScript);
 }
 
 function func()
 {
     varyvar.stringy = "Yey, it works"
 }

This is the unityscript.js file. It's just an example ,sorry if I wasn't clear enough.

Thank you.

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
Best Answer

Answer by Kiwasi · Aug 07, 2014 at 06:27 PM

Yes. Check out the docs here.

Note that while it can be done, most people on UA generally recommend against it. Ultimately its a pain to do. Tends to be easier if all scripts are in the same language.

Comment
Add comment · Show 1 · 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 Ssiroo · Aug 07, 2014 at 06:58 PM 0
Share

Guys I fixed it.

What I did was I just created a new folder named Plugins and put the scripts in there. That way unity checks them first. Then I used a simple unityscript to access the variables.

Thank you all for trying to help me!

avatar image
-3

Answer by Foose · Aug 07, 2014 at 06:26 PM

i really dont understand what you are trying there. u can code in js, c# and boo with unity. doesnt matter. So basically u can make one script out of them when u change the unityscript file to cs.

Edit: If you really want to keep the two scripts seperate, I can give you an example how it will work in c# but no clue how it is in js.

Attach the script with the string to a gameobject. Now in your unityscript reference to this script by calling

 ScriptyScript str = GameObject.Find("[name of the go the script is attached to]").GetComponent<ScriptyScript>();
 
 
 str.stringy //is the command you will be using in your unity script to  get the stringy variable of the other script) 

Comment
Add comment · Show 6 · 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 Kiwasi · Aug 07, 2014 at 06:28 PM 0
Share

Actually it does matter. Scripts in different languages can't access each other without some special trickery.

avatar image Foose · Aug 07, 2014 at 06:33 PM 0
Share

actually downvoting me because you cannot read, isnt cool you know?. I simply said that there is no difference between a c# script and a unityscript because in unity u can progamm in c+ too and unityscript doesnt automatically mean js.

avatar image meat5000 ♦ · Aug 07, 2014 at 06:38 PM 0
Share

He didn't downvote you 4 times, that's an absolute dead cert. (I didn't downvote you at all).

Save your $$anonymous$$arma, delete the answer.

avatar image tanoshimi · Aug 07, 2014 at 06:39 PM 2
Share

Downvoting because you're talking utter nonsense...

"There's no difference between a c# script and a unity script"

"In unity you can program$$anonymous$$g in c+ too"

"Unityscript doesn't automatically mean js"

Wrong, wrong, and er, wrong :)

avatar image Ssiroo · Aug 07, 2014 at 06:46 PM 0
Share

Im actualy trying to access a c# script via unityscript but it's giving me this error :

BCE0005: $$anonymous$$ identifier: 'NA$$anonymous$$EOFTHESCRIPT'.

Long time ago someone told me it doesn't work but then I saw a lot of people actually do it by putting both scripts in the same folder but...it's not working for me.

Show more comments

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

23 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

Related Questions

Trigger player movement on touch 1 Answer

Hide the ImageTraget in Real world 0 Answers

How to go about modifying a variable in a C# script from within a UnityScript (Javascript) that resides in a different Gameobject? 1 Answer

how to acess Static variable in other scripts without extended functions? 2 Answers

Multiple Cars not working 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