I never thought I would go to the times where I was flooding the forum with questions, but it is seems that U3 won’t let me off the hook !
The faulty line is :
The function is :
function GetEnvironmentDataCopy () : Object []
{
if (environmentData)
{
var environmentDataCopy : Object [] = new Object [environmentData.length];
for (var y : int = 0; y < environmentData.length; y++)
{
var rowOriginal : Hashtable [] = environmentData [y];
var rowCopy : Hashtable [] = new Hashtable [rowOriginal.length];
environmentDataCopy [y] = rowCopy;
for (var x : int = 0; x < rowOriginal.length; x++)
{
var dataOriginal : Hashtable = rowOriginal [x];
var dataCopy : Hashtable = new Hashtable (dataOriginal);
rowCopy [x] = dataCopy;
}
}
return environmentDataCopy;
}
else
{
Debug.LogError ("No environment data to clone");
Debug.Break ();
}
}
AkilaeTribe, are your environment variables fixed? That is, will you always have “SkyColour”, “FloorSize”, and so on, or will you be dynamically adding unique ones at run-time? Like would the user be adding their own with their own custom name?
If they are all fixed names, then unless you have tonnes and tonnes of properties, perhaps you should consider making a custom class with those names as properties; might be easier to copy and manage.
I appreciate your efforts but the problem come from new Hashtable (dataOriginal) it seems that Unity won’t let me create a new Hashtable and copying at the same time all the key/values of the original Hashtable.
Working as intended, or bug, I can only wait for someone to read that topic and answer
var ht;
var hclone;
function Awake()
{
ht = new Hashtable();
hclone = new Hashtable();
}
function Start()
{
ht.Add("1", "one");
ht.Add("2", "two");
ht.Add("3", "three");
Debug.Log("ht contains " + ht.Count + " items and hclone contains " + hclone.Count + " items, performing copy from ht to hclone");
for (entry in ht)
{
var key = entry.Key;
var value = entry.Value;
hclone.Add(key, value);
}
Debug.Log("ht contains " + ht.Count + " items and hclone contains " + hclone.Count + " items, should equal ht, now clearning ht");
ht.Clear();
Debug.Log("ht contains " + ht.Count + " items and hclone contains " + hclone.Count + " items, ht should be empty and hclone has our items");
Debug.Log("Showing our hclone items now");
for (de in hclone)
{
Debug.Log("Key = "+de.Key+ ", Value = " + de.Value);
}
Debug.Log("showing our ht items, should be empty");
for (de in ht)
{
Debug.Log("Key = " + de.Key + ", Value = " + de.Value);
}
}