private static void DrawCore(int instanceID, Rect selectionRect) { // skips early if item is not registered or not valid if (!sceneGameObjects.ContainsKey(instanceID)) { return; } currentGO = EditorUtility.InstanceIDToObject(instanceID) as GameObject; if (currentGO == null) { return; } currentItem = sceneGameObjects[instanceID]; /* Initialzie draw variables */ { bool alphaSorted = HierarchyWindowAdapter.IsUsingAlphaSort(); if (ALPHA_SORTED != alphaSorted) { ALPHA_SORTED = alphaSorted; // This is bad since we retrieve data twice when the user // changes their hierarchy sorting type. // // Yet this may be okay since the user doesn't change // the sorting type that often. RetrieveDataFromHierarchy(); } ROW_HEIGHT = GUI.skin.label.lineHeight + 1; // default is 16 pixels MAX_TAG_LEN = HierarchyUtil.MaxLabelLength(tags.ToArray(), (data.tag.GetEnabled() && data.tag.enabledText)); MAX_LAYER_LEN = HierarchyUtil.MaxLabelLength(layers.ToArray(), (data.layer.GetEnabled() && data.layer.enabledText)); MAX_INSTID_LEN = HierarchyUtil.MaxIntLength(instanceIDs.ToArray(), data.instanceID.GetEnabled()); RIGHT_BOUNDARY = 0.0f; // reset if (EXISTS_PREFAB_ICON) { RIGHT_BOUNDARY += ROW_HEIGHT; } } //-- Full DrawAlternatingBG(instanceID, selectionRect); DrawTree(instanceID, selectionRect); DrawSeparators(instanceID, selectionRect); //-- Left DrawIcons(instanceID, selectionRect); DrawLog(instanceID, selectionRect); //-- Right DrawComponents(instanceID, selectionRect); DrawTag(instanceID, selectionRect); DrawLayer(instanceID, selectionRect); DrawInstanceID(instanceID, selectionRect); }
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; } } } }