• 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 3D-Magic-VR · Oct 28, 2011 at 03:23 AM · c#javascriptobjectlist

JS to C# List type problem

Hello every body, I got a little problem:

How I can convert an object list javascript to c # without changing the object type, something like this:

 // JavaScript Data
 var holder : _Holder // "type object" - the inspector will show the variables of the script (_Holder).
 //
 // JavaScript _Holder
 var numbers : int;
 var groups : boolean[];
 ----
 ----
 // C# Data
 public _Holder holder; // "type _Holder" - this shows a picker of objects instead of shows the variables of the script(_Holder).
 //
 // C# _Holder
 public int numbers;
 public bool[] groups;

my question is, how I can preserve the value "object" in c #?.

hopes any one can help me, thanks in advance.

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 syclamoth · Oct 28, 2011 at 03:37 AM 0
Share

I'm not sure exactly what you are trying to do here. What's going wrong here? Is the C# _Holder a $$anonymous$$onoBehviour, or a base class? I don't quite understand the problem, I'm afraid. Is it something to do with the [System.Serializable] tag?

avatar image 3D-Magic-VR · Oct 28, 2011 at 05:18 AM 0
Share

the _Holder in js it's public class type and the cs _Holder it's $$anonymous$$onoBehaviour class

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by syclamoth · Oct 28, 2011 at 05:35 AM

Don't make the cs _Holder derive from monoBehaviour. Where it says

 public class _Holder : MonoBehaviour {
     // whatever you have in it
 }

just have

 [System.Serializable]
 public class _Holder {
     some stuff
 }

As long as you never have to use _Holder as a component, this is the best way to do it.

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 3D-Magic-VR · Oct 28, 2011 at 05:52 AM 0
Share

Thank you very much, it helps me a lot, you really save my day, I think need to do more research about all coding stuff, once again thank you.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Disable GameObject Only Father Not Children 2 Answers

Calling a C# function from a Javascript 3 Answers

Translate c script in java 1 Answer

Distribute terrain in zones 3 Answers

Getting error BCE0024, while the constructor exists 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