The problem is that i loop over the objects array. objects is array of selection gameobjects.
When i loop over it and create the toggles then when i check/uncheck a single toggle box it's checking/unchecking all the toggles. how can i make that it will toggle only single ?
The one i checked i want only him to be enabled true/false.
The loop part :
for (int i = 0; i < objects.Length; i )
{
EditorGUIUtility.labelWidth = 50;
EditorGUILayout.BeginHorizontal();
{
GUILayoutOption[] options = { GUILayout.MaxWidth(300.0f), GUILayout.MinWidth(300.0f) };
objects[i] = (GameObject)EditorGUILayout.ObjectField(i.ToString(), objects[i], typeof(GameObject), true, options);
EditorGUIUtility.labelWidth = 112;
include1 = EditorGUILayout.Toggle("Include Children", include1, GUILayout.ExpandWidth(true));
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndScrollView();
EditorGUI.indentLevel--;
}
The include1 are the toggles i want to be able to enable true/false individual.
The rest of the code :
public void OnGUI()
{
GUILayout.Space(10);
childrenPrefix = EditorGUILayout.TextField("Rename prefix", childrenPrefix);
startIndex = EditorGUILayout.IntField("Start index", startIndex);
includeChildren = EditorGUILayout.Toggle("Include Children", includeChildren);
if (objects.Length == 0)
{
showPosition = false;
}
GUILayout.Space(20);
EditorGUI.BeginChangeCheck();
EditorGUILayout.GetControlRect(true, 16f, EditorStyles.foldout);
Rect foldRect = GUILayoutUtility.GetLastRect();
if (Event.current.type == EventType.MouseUp && foldRect.Contains(Event.current.mousePosition))
{
showPosition = !showPosition;
GUI.changed = true;
Event.current.Use();
}
showPosition = EditorGUI.Foldout(foldRect, showPosition, "Objects");
GUILayout.Space(2);
if (showPosition)
{
EditorGUI.indentLevel ;
scrollPos =
EditorGUILayout.BeginScrollView(scrollPos);
for (int i = 0; i < objects.Length; i )
{
EditorGUIUtility.labelWidth = 50;
EditorGUILayout.BeginHorizontal();
{
GUILayoutOption[] options = { GUILayout.MaxWidth(300.0f), GUILayout.MinWidth(300.0f) };
objects[i] = (GameObject)EditorGUILayout.ObjectField(i.ToString(), objects[i], typeof(GameObject), true, options);
EditorGUIUtility.labelWidth = 112;
include1 = EditorGUILayout.Toggle("Include Children", include1, GUILayout.ExpandWidth(true));
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndScrollView();
EditorGUI.indentLevel--;
}
GUILayout.FlexibleSpace();
if (GUILayout.Button("Rename Objects"))
{
}
Repaint();
}
CodePudding user response:
Make your include1 an array of bool so each item has its own value