public bool Update(Transform t, int depth) { var rect = EditorGUILayout.BeginHorizontal(); { if (isVariable) { EditorGUI.DrawRect(rect, new Color(0, 0.5f, 0, 0.3f)); } isVariable = EditorGUILayout.ToggleLeft("变量", isVariable, toggleMaxWidth); if (!isVariable) { isAttribute = false; isEvent = false; } { GUI.enabled = isVariable; isAttribute = EditorGUILayout.ToggleLeft("属性器", isAttribute, toggleMaxWidth); GUI.enabled = !isVariable? false:isSelectEvent; isEvent = EditorGUILayout.ToggleLeft("事件", isEvent, toggleMaxWidth); GUI.enabled = true; } oldIndex = index; comNames = QGlobalFun.GetComponentsName(t); index = EditorGUILayout.Popup(index, comNames, popupMaxWidth); if (oldIndex != index) { onTypeChanged(comNames[index]); } GUILayout.Space(depth * space); if (t.childCount > 0) { isOpen = EditorGUILayout.Foldout(isOpen, t.name, true); } else { EditorGUILayout.LabelField(t.name); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); return(isOpen); }
public void SetIndex(string name, Transform t) { comNames = QGlobalFun.GetComponentsName(t); int count = comNames.Length; for (int i = 0; i < count; i++) { if (name == comNames[i]) { index = i; break; } } }