I'm a bit noobish. I was translating a java script to c# and I'm getting 3 errors dealing with my Contents and newContent arrays. These 3 errors are the exact same for line 23. Can someone please help me?
1. error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected
2. error CS1502: The best overloaded method match for `System.Collections.ArrayList.ToArray(System.Type)' has some invalid arguments
3. error CS1503: Argument `#1' cannot convert `object' expression to type `System.Type'
The script -
using UnityEngine;
using System.Collections;
public class Inventory : MonoBehaviour {
Transform[] Contents;
public void AddItem ( Transform Item ){
ArrayList newContents = new ArrayList(Contents);
newContents.Add(Item);
Contents = newContents.ToArray(Transform);
}
public void RemoveItem ( Transform Item ){
print("made it here");
ArrayList newContents = new ArrayList(Contents);
int index = 0;
bool shouldend = false;
foreach(Transform i in newContents){
if(i==Item){
newContents.RemoveAt(index);
shouldend = true;
}
index++;
if(shouldend){
Contents = newContents.ToArray(Transform);
return;
}
}
}
}
↧