Saving/Outputting an Integer 3D array (int[,,])

Hey guys! I am making an ingame editor, and I need to save my integer 3D array data and output it. By outputting I mean something like I have a GUI Textfield with bunch of numbers separated by commas, that are basically forming the array. I would like it working like, I change something in array, the textfield changes, I change the textfield, the array changes too. How can I output/save it?

– David

If by ‘save’ you mean to a file then System.IO Namespaces () | Microsoft Learn
If all you want to do is get text to and from text field/array, then String.Split Method (System) | Microsoft Learn

I believe this script does what you're after:


/* array of ints */

var arrayOfInts   :  int []  =  [14, 18, 24, 36, 33];

/* rectangle for GUI stuff */

var guiRect       :  Rect    =  Rect(200, 200, 200, 200);

function OnGUI ()
{
    /* a variable used to represent the array of ints as a string */

    var ourString = buildIntString();

    /* draw the gui */

    GUILayout.BeginArea(guiRect);

    GUILayout.Box("Size of array: " + arrayOfInts.length);

    /* put the user's input in a different string */

    var userString = GUILayout.TextField(ourString);

    GUILayout.EndArea();

    var tempStringArray :  String []  =  userString.Split(","[0]);

    var tempIntArray    :  int    []  =  new int [ tempStringArray.length ];

    for ( var i = 0; i < tempStringArray.length; i ++ ) {

        var tempInt : int = int.Parse(tempStringArray*);*
 _tempIntArray *= tempInt;*_
 _*}*_
 _*arrayOfInts = tempIntArray;*_
_*}*_
_*function buildIntString ()*_
_*{*_
 _*var theResult : String = arrayOfInts[0];*_
 _*for ( var j = 1; j < arrayOfInts.length; j ++ ) {*_
 _*theResult += ", " + arrayOfInts[j];*_
 _*}*_
 _*return theResult;*_
_*}*_
_*```*_
_*<p>I will clean it up in a moment and add some error checking...</p>*_
_*<p>I have to run out the door, but it would be easy to use a regex to make sure the user can only enter valid characters (numbers and commas).</p>*_