I had a script that’s been working fine, the only thing that’s been different is I changed it to Monobehaviour. After I’ve done this I can no longer get the length of my arrays. I can still access the arrays as if they are, but I cant get their length anymore. The Array.length option doesn’t even show up in the tips while typing. And if I type it anyway I’ll get “unresolved member” error when I scroll over it. And in Unity I get:
Assets/Scripts/Player/AttackClass.cs(79,46): error CS1061: Type ComboFrames[]' does not contain a definition for
length’ and no extension method length' of type
ComboFrames’ could be found (are you missing a using directive or an assembly reference?)
public class AttackClass : MonoBehaviour
{
public ComboFrames[] GroundCombo;
public ComboFrames[] AirCombo;
//Ints that hold the max number of combos for the attacks.
private int maxCombo;
private int maxComboGround;
public int[] testing;
void Awake()
{
Debug.Log(testing.Length);
Debug.Log(GroundCombo[0].start);
maxComboGround = GroundCombo.Length;
Debug.Log(maxComboGround);
}
}
[System.Serializable]
public class ComboFrames
{
public int start;
public int active;
public int ending;
/// <summary>
/// Amount of frames allowed for input into next combo.
/// </summary>
public int combo;
}
The GroundCombo[0].start works just fine, so its an Array and it exists… However ‘length’ or any other array extensions just aren’t there. The ‘testing’ integer array works fine with the extensions. Do class arrays not work with array extensions when you’re using Monobehaviour? Are there any work arounds?
Update:
Stopped having a problem and was working fine, then it suddenly stopped working again. What I noticed is when I scroll over a declaration of GroundCombo and the tooltip comes up. It doesn’t show ComboFrames like it would with testing showing int, it just shows up ComboFrames as if it isn’t even an array, just a single instance.
Seems like this is more of an issue with MonoDev than Unity. This question can be closed.