void SetItemSelectedIcon(GameObjectTreeViewItem item)
 {
     if (item.icon != null)
     {
         item.selectedIcon = EditorUtility.GetIconInActiveState(item.icon) as Texture2D;
     }
 }
        void ShowOption(BuildPlatform bp, GUIContent title, GUIStyle background)
        {
            Rect r = GUILayoutUtility.GetRect(50, 36);

            r.x += 1;
            r.y += 1;
            bool valid = BuildPipeline.LicenseCheck(bp.defaultTarget);

            GUI.contentColor = new Color(1, 1, 1, valid ? 1 : .7f);
            bool selected = EditorUserBuildSettings.selectedBuildTargetGroup == bp.targetGroup;

            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, GUIContent.none, false, false, selected, false);

                Texture image = null;

                if (selected && title.image)
                {
                    image = EditorUtility.GetIconInActiveState(title.image);
                }

                if (image == null)
                {
                    image = title.image;
                }

                GUI.Label(new Rect(r.x + 3, r.y + 3, 32, 32), image, GUIStyle.none);

                if (EditorUserBuildSettings.activeBuildTargetGroup == bp.targetGroup)
                {
                    GUI.Label(new Rect(r.xMax - styles.activePlatformIcon.width - 8, r.y + 3 + (32 - styles.activePlatformIcon.height) / 2,
                                       styles.activePlatformIcon.width, styles.activePlatformIcon.height),
                              styles.activePlatformIcon, GUIStyle.none);
                }
            }

            if (GUI.Toggle(r, selected, title.text, styles.platformSelector))
            {
                if (EditorUserBuildSettings.selectedBuildTargetGroup != bp.targetGroup)
                {
                    EditorUserBuildSettings.selectedBuildTargetGroup = bp.targetGroup;

                    // Repaint inspectors, as they may be showing platform target specific things.
                    Object[] inspectors = Resources.FindObjectsOfTypeAll(typeof(InspectorWindow));
                    for (int i = 0; i < inspectors.Length; i++)
                    {
                        InspectorWindow inspector = inspectors[i] as InspectorWindow;
                        if (inspector != null)
                        {
                            inspector.Repaint();
                        }
                    }
                }
            }
        }