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 Alp-Giray-Savrum · Sep 03, 2013 at 01:36 PM · listarraysaddingjava to c#js - c#

How to add item to Script Written in C# ?

Hello again, I wrote 2 script sheets. One of them is C# and other is JS.

So, I've got an array list in C#, I want to add new items with my javascript. But MonoDevelop can't shows the script in code suggestions :/

As you can see at the picture below ;

alt text

There's ArrayListForDucks is opened at tab, but doesn't seen by Mono ? So what can i do ? All Variables are Static.

adsız.png (55.0 kB)
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

1 Reply

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

Answer by ArkaneX · Sep 03, 2013 at 02:59 PM

The problem is that C# project and JS project are separate and types in one of them doesn't know about types in second. You can trick this behavior by putting ArrayListForDucks.cs into Assets\\Plugins folder (see this question for explanation).

But if you don't have to use different languages, then just stick to either C# or JS.

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 fafase · Sep 03, 2013 at 03:06 PM 0
Share

Your answer looks right but somehow wrongly said. Projects are not really separate, they use different compilers. So it is possible to have one class seeing the other but it won't do the other way. You cannot have two ways communication between two classes and the way to communicate is as you claim, putting the one to be looked at in the Plugins or StandardAsset folders.

avatar image ArkaneX · Sep 03, 2013 at 03:19 PM 0
Share

By 'separate', I mean they don't reference each other. If you drop your script to the Plugins folder, a third project is created and its reference is added to both C# and JS projects.

I don't use $$anonymous$$onoDevelop, so maybe it behaves differently, but in Visual Studio I can't see standard JS classes in C# as well as C# classes in JS.

avatar image Alp-Giray-Savrum · Sep 03, 2013 at 03:26 PM 0
Share

I don't know how to use "List" method at JS, Sorry I'm 14 years old :/ At my other questions they told if you want to use something with arrays use List method with C#, So i wrote this but I'dont know how to write my other code at C# :/

avatar image ArkaneX · Sep 03, 2013 at 03:48 PM 2
Share

In order to use generic List in JS, you have to import proper namespace:

 import System.Collections.Generic;

and then, to create List of string elements, you can use:

 var list : List.<String> = new List.<String>();
 list.Add("aaa");
 list.Add("bbb");
 for(var x : String in list)
 {
     print(x);
 }

You can read more about generic lists here. Scroll to bottom of the page to see examples. JavaScript (UnityScript) notation is a bit different, because you have to use additional dot character before type info (like in my example).

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

17 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

Related Questions

A node in a childnode? 1 Answer

How To Get A Reference To All Nearby GameObjects? 1 Answer

How do i convert this code snippet to a list? 1 Answer

[C#]Inventory script help. 3 Answers

UnityScript for unique simpleJSON lists 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