diff --git a/Scripts/UI/Toolbar.cs b/Scripts/UI/Toolbar.cs index 3b578b0c..c8550790 100644 --- a/Scripts/UI/Toolbar.cs +++ b/Scripts/UI/Toolbar.cs @@ -494,11 +494,12 @@ static void OnPrimitiveMenuGUI(int windowID) { List compoundBrushTypes = CompoundBrush.FindAllInAssembly(); for (int i = 0; i < compoundBrushTypes.Count; i++) { + int j = i; // Closure causes "i" to be "2" in the lambda expression unless we assign it to a scoped variable. menu.AddItem ( new GUIContent (compoundBrushTypes[i].Name), false, () => { - CreateCompoundBrush(compoundBrushTypes[i]); + CreateCompoundBrush(compoundBrushTypes[j]); primitiveMenuShowing = false; } );