- Home /
Use for loops and still assign gameObjects in editor
Hi everyone. Sorry if my title is confusing. I was wondering if there was a way to use for loops to make multiple gameObject fields, but still be able to assign gameObjects. The problem is that the user can resize the array, so I have to call new GameObject[number]
every frame, so the objects cannot be set. All help is appreciated!!! :)
Would it be possible for you to post some example code to give some additional context?
Answer by karl_ · May 01, 2011 at 03:11 PM
Instead of using a built-in array, I'd suggest a List. This will allow you to resize at will thus avoiding the issue of clearing the array out every time you'd like to change array size.
import System.Collections.Generic; var obj : List.<GameObject> = new List.<GameObject>();
// Creates a drag and drop column for gameobjects. for(i = 0; i < obj.Count; i++) { obj[i] = EditorGUILayout.ObjectField(obj[i], GameObject); }
Your answer
Follow this Question
Related Questions
Simple problem: Can't save Input in Editor GUI's Propertyfield. 0 Answers
Resizing an array of gameObjects 2 Answers
Need Ideas How To Get Started With A In Game Computer? 1 Answer
GUI Appear Help 1 Answer