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 DavidDebnar · Jul 11, 2011 at 12:36 PM · variablepluginscompilingdeclaration

Custom variable declared in JS, that isn't in plugins.

Hey... I'm rewriting things to JavaScript, and I ran into a problem. How can I declare a custom variable like var myScript : MyScript, when the variable script isn't in plugins? Because I have a problem that when it is in plugins, and is compiled before another script there is a error.

  • David

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 Joshua · Jul 11, 2011 at 12:38 PM 0
Share

Is this script in the same language as the one you´re writing in?

avatar image DavidDebnar · Jul 11, 2011 at 12:39 PM 0
Share

The $$anonymous$$yScript is C#, and the script I wanna declare the war in is JavaScript, and that's the problem...I can rewrite even that $$anonymous$$yScript...But if it's not needed...

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Joshua · Jul 11, 2011 at 12:44 PM

The only way to reference a variable in a script in an other language, is if it is higher in the compilation order. It does not have to be in plugins, it can also be in standard assets, but that's it. Why can't you place this script in there?

http://unity3d.com/support/documentation/ScriptReference/index.Script_compilation_28Advanced29.html

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 DavidDebnar · Jul 11, 2011 at 12:53 PM 0
Share

I know about that compilation order, I can't place it there, because the $$anonymous$$yScript.cs gets a variable from another scipt, and shows and if it's in Plugins/SA I show that "The type or namespace name TQueue1' could not be found. Are you missing a using directive or an assembly reference?"

The code for declaring is public TQueue[] FinishedChunks = new TQueue[](); without the []

avatar image Bunny83 · Jul 11, 2011 at 01:07 PM 1
Share

That's why you shouldn't mix different languages. You can use single scripts (that work in itself) from other languages but crossreferences between languages is not a good idea. If it's a huge project it's just a mess.

avatar image Joshua · Jul 11, 2011 at 01:14 PM 0
Share

If you do go cross language it's a one way stream, that's the main thing to remember.

avatar image aldonaletto · Jul 11, 2011 at 01:20 PM 1
Share

A script stored in a non-standard folder (a folder created by you in Assets) will be compiled last, what enables it to "see" all scripts already compiled (scripts in standard folders). If the JS script is in a folder like this, it will be able to find $$anonymous$$yScript in a C# script stored in any standard folder. The problem, of course, is that nobody at the standard folders will know it. I use several static vars in a central script to exchange information between incompatible scripts, but it isn't enough sometimes.

avatar image Joshua · Jul 11, 2011 at 01:45 PM 1
Share

That sounds like a real pain, aldonaletto. I ussually just go with rewriting it in the correct language.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Can I get a warning if I (involuntarily) declare a new js variable in an assignment? 2 Answers

C# - Simple Optimization / Variable Declaration 1 Answer

UnityException: You are not allowed to call this function when declaring a variable. Move it to the line after without a variable declaration 1 Answer

Declaring a variable in Start funciton 3 Answers

Does it matter to declare variable type? 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