x


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.

more ▼

asked Oct 28 '11 at 03:23 AM

3D-Magic-VR gravatar image

3D-Magic-VR
41 12 14 15

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

Oct 28 '11 at 03:37 AM syclamoth

the _Holder in js it's public class type and the cs _Holder it's MonoBehaviour class

Oct 28 '11 at 05:18 AM 3D-Magic-VR
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Oct 28 '11 at 05:35 AM

syclamoth gravatar image

syclamoth
15k 7 15 80

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.

Oct 28 '11 at 05:52 AM 3D-Magic-VR
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4374
x3570
x3419
x1123
x382

asked: Oct 28 '11 at 03:23 AM

Seen: 1227 times

Last Updated: Mar 19 '12 at 05:00 AM