コード例 #1
0
        private static void DrawIcons(int instanceID, Rect selectionRect)
        {
            if (!data.icons.GetEnabled())
            {
                return;
            }

            bool defaultIcon = false;

            // Draws the gameobject icon, if present
            var content = EditorGUIUtility.ObjectContent(currentGO, null);
            var image   = content.image;

            bool validImage = (image && !string.IsNullOrEmpty(image.name));

            if (validImage)
            {
                defaultIcon = (image.name == "d_GameObject Icon");

                HierarchyWindowAdapter.ApplyIconByInstanceId(instanceID, content.image);
            }
            else
            {
                HierarchyWindowAdapter.ApplyIconByInstanceId(instanceID, HierarchyUtil.BrokenIcon());
            }

            if (defaultIcon && data.icons.guess)
            {
                foreach (var comp in currentItem.components)
                {
                    if (comp == null)
                    {
                        continue;
                    }

                    var t        = comp.GetType();
                    var typeName = t.ToString();

                    {
                        var lst = typeName.Split('.');
                        typeName = lst[lst.Length - 1];
                    }

                    if (HierarchyUtil.ContainString(typeName, currentItem.goName))
                    {
                        var compImage = HierarchyUtil.TypeTexture(comp, t);
                        HierarchyWindowAdapter.ApplyIconByInstanceId(instanceID, compImage);
                        currentItem.guessedComponent = comp;
                        break;
                    }
                }
            }
        }