示例#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;
                    }
                }
            }
        }
示例#2
0
        private static void DrawComponents(int instanceID, Rect selectionRect)
        {
            if (!data.components.GetEnabled())
            {
                return;
            }

            temp_iconsDrawedCount = 0;
            float offsetX_const = 3;
            float offsetX       = RIGHT_BOUNDARY + offsetX_const + MAX_TAG_LEN + MAX_LAYER_LEN + MAX_INSTID_LEN;

            bool omitComp    = data.icons.omitComp;
            bool guessedComp = (currentItem.guessedComponent != null);

            foreach (Component comp in currentItem.components)
            {
                if (omitComp && guessedComp && comp == currentItem.guessedComponent)
                {
                    continue;
                }

                // When component is null, meaning there is broken link
                // so here we accept null value.
                var t     = (comp == null) ? null : comp.GetType();
                var image = HierarchyUtil.TypeTexture(comp, t);

                float offset = offsetX + (ROW_HEIGHT * temp_iconsDrawedCount);
                float x      = selectionRect.xMax - offset;
                Rect  rect   = new Rect(x, selectionRect.yMin, ROW_HEIGHT, ROW_HEIGHT);

                HierarchyRenderer.DrawComponent(t, currentGO, rect, image);

                if (data.components.focus && GUI.Button(rect, "", "Label"))
                {
                    OnClick_Component(instanceID, t);
                }

                ++temp_iconsDrawedCount;
            }
        }