- Home /
Other
get length of array c#
hello everyone, here is an easy question. I have spend days looking everywhere on how to get the length of an array on c#, the way I have it set up now is the following:
public Transform[] transformArray;
void Update (){
Debug.log("Array length is:" + transformArray.Length);
}
well at least this is what i am trying to do but not only the "Length" doesent apear in the options, when i put it it retourns an error. if some one know what am i doing wrong pls tell, i am loosing sleep, i dont get how is something so used be so damn hard to do for me. thank you all in advanced.
all correct except
Debug.log
that have to be
Debug.Log
the array builtin is a a row type so there isn't need to inizialize and to access the dimension Length is correct, so .. boh XD
Did you add any transform in the inspector? if not add some then debug in Start() ins$$anonymous$$d of Update() just for testing.
@Benproductions1 You're fast! I deleted my comment because the use of an Update method does strongly imply a $$anonymous$$onoBehaviour. On a side note, what's the markup for 'preformatted' text as you used in your comment above?
Edit: corrected misspelling if name benproductions => Benproductions1
@iwaldrop you forgot the "1" when referencing my name :P (That "1" is very important to me XD)
I's funny we came to the same conclusion, the way you do the special formatting
is using the ` character ;) (You're the first person to ask that, so thumbs up to you sir!)
Answer by unimechanic · Feb 21, 2014 at 07:37 PM
Question solved by user who closed it without answering. Adding this answer to remove it from the Unanswered view and give more relevance to other questions requiring attention. Thanks for your comprehension, Unity Support.
Follow this Question
Related Questions
Static Array - Throwing NullReference 1 Answer
variables based on array.length not updating in JS 1 Answer
How to add an object to an array? 1 Answer
Why is this array out of length? 1 Answer