- Home /
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.
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?
the _Holder in js it's public class type and the cs _Holder it's $$anonymous$$onoBehaviour class
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.
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
Follow this Question
Related Questions
Help| Convert a javascript to C# 1 Answer
C# Custom Object Editor Error 2 Answers
One script, different variable for each object. 1 Answer
Can a script be loaded to a next scene? 3 Answers