Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

Cant get helper C# class into UnityScript variable

Discussion in 'Scripting' started by cdalexander, Oct 5, 2010.

  1. cdalexander

    cdalexander

    Joined:
    Nov 9, 2009
    Posts:
    73
    I wrote a C# class with a number of parsing functions for a large string of data. I want to call it like this:

    Code (csharp):
    1. var dataToParse = "..very..long..string";
    2. var myData: MyClassName = new MyClassName (dataToParse);
    3.  
    4. myData.Parse();
    5. myData.Count();
    6. myData.Execute();
    7. // Ect...
    In my CS file I have something like:
    Code (csharp):
    1. public class MyClassName : MonoBehaviour{
    2.  
    3.   private string _rawCode;
    4.   private ArrayList _parsedCode;
    5.  
    6.  // I can't get a constructor to work
    7.   void Init(string dataIn) {
    8.     _rawCode = dataIn;
    9.   }
    10.  
    11.   public int Count () {
    12.     return _parsedCode.Length;
    13.   }
    14.  
    15.   ...
    16.  
    17. }
    18.  
    When I try to define in it in the UnityScript code, I get this error:
    I recall getting something like this to work a while ago in Unity v2.x. I've upgraded to v3.0 and I'm tripping over what I thought was a pretty common usage of a helper class. Have things changed and how does one do this in v3.0?

    Thanks for any info!
     
    Last edited: Oct 5, 2010
  2. Chris Sinclair

    Chris Sinclair

    Joined:
    Jun 14, 2010
    Posts:
    1,326
unityunity