private void SaveLastColor()
 {
     InspectorEditorHelper.PushColor();
 }
 private void RestoreLastColor()
 {
     InspectorEditorHelper.PopColor();
 }
        private void OnGUI()
        {
            _target     = EditorGUILayout.ObjectField("select object or component:", _target, typeof(Object), true);
            GUI.enabled = _target != null;
            if (GUILayout.Button("Inspect"))
            {
                InspectorEditorWindow.Open(_target, _target.ToString(), true, true);
            }
            GUI.enabled = true;

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            var objects = Selection.objects;

            if (!IsEquals(objects, _selectedObjects))
            {
                _selectedObjects        = Selection.objects;
                _selectedObjectsFoldout = new bool[_selectedObjects.Length];
            }

            Object inspectTarget = null;
            var    index         = 0;

            foreach (var target in objects)
            {
                _selectedObjectsFoldout[index] = InspectorEditorHelper.FoldoutHeader(target.ToString(), _selectedObjectsFoldout[index]);
                if (_selectedObjectsFoldout[index])
                {
                    InspectorEditorHelper.BeginVertical();
                    if (GUILayout.Button("Inspect", InspectorStyles.minibuttonmid))
                    {
                        inspectTarget = target;
                        break;
                    }
                    var go     = target as GameObject;
                    var stoped = false;
                    if (go != null)
                    {
                        GUILayout.Label("Inspect components:");
                        EditorGUILayout.BeginHorizontal(EditorStyles.label);
                        EditorGUILayout.Space();
                        EditorGUILayout.BeginVertical();
                        foreach (var component in go.GetComponents(typeof(Component)))
                        {
                            if (component != null)
                            {
                                if (GUILayout.Button(component.ToString(), InspectorStyles.minibuttonmid))
                                {
                                    inspectTarget = component;
                                    stoped        = true;
                                    break;
                                }
                            }
                            else
                            {
                                GUILayout.Label("missing script", InspectorStyles.flow_background);
                            }
                        }
                        EditorGUILayout.EndVertical();
                        EditorGUILayout.EndHorizontal();
                    }
                    InspectorEditorHelper.EndVertical();
                    if (stoped)
                    {
                        break;
                    }
                }
                index++;
            }
            if (inspectTarget != null)
            {
                InspectorEditorWindow.Open(inspectTarget, inspectTarget.ToString(), true, true);
            }
        }