internal static void DrawTypeIcon(Rect position, GameObject obj, GrendelFolderComponent folderComponent) { GUIContent customIcon = new GUIContent(); GUIContent typeIcon = new GUIContent(); bool hasCustomIcon = false; Color previousGUIColor = GUI.color; customIcon = new GUIContent(EditorGUIUtility.ObjectContent(obj, obj.GetType())); if (folderComponent == null) { typeIcon = new GUIContent(EditorGUIUtility.ObjectContent(null, TryGetFirstNonTransformComponentType(obj.GetComponents <Component>()))); hasCustomIcon = (customIcon.image != sGameObjectIcon.image) && (customIcon.image != sPrefabIcon.image) && (customIcon.image != sPrefabModelIcon.image) && (customIcon.image != sPrefabNormalIcon.image); } else { Color folderColor = folderComponent.FolderColor; folderColor.a = 1f; GUI.color = Color.Lerp(GUI.color, folderColor, folderComponent.FolderColor.a); typeIcon = new GUIContent(GrendelEditorIcons.FolderIcon); } GUI.Label(position, hasCustomIcon ? customIcon.image : typeIcon.image, sCustomIconStyle); GUI.color = previousGUIColor; }
public static void DrawFolder(Rect pos, GrendelFolderComponent folder, Color rowColor) { if (sLabelStyle == null) { sLabelStyle = new GUIStyle(EditorStyles.label); sLabelStyle.alignment = TextAnchor.MiddleLeft; } Rect position = new Rect(pos); int childCount = folder.transform.childCount; position.height -= 4f; position.y += 2f; GrendelHierarchyView.DrawBackground(position, rowColor, EditorGUIUtility.whiteTexture, false); if (childCount > 0) { position.width -= GrendelHierarchyView.kIconWidth; position.x += GrendelHierarchyView.kIconWidth; position.x += GrendelHierarchyView.kIconBufferWidth; } GrendelHierarchyView.DrawBackground(position, folder.FolderColor, GrendelFolder.FolderBGTexture, false); position.height += 4f; position.y -= 2f; position.x += GrendelHierarchyView.kIconBufferWidth * 2; GUI.Label(position, folder.transform.name, sLabelStyle); position.width = GrendelHierarchyView.kIconWidth; position.x -= GrendelHierarchyView.kIconWidth; position.x -= GrendelHierarchyView.kIconBufferWidth * 2f; Color previousGUIColor = GUI.color; GUI.color = folder.FolderColor; GUI.DrawTexture(position, childCount > 0 ? GrendelEditorIcons.FolderIcon : GrendelEditorIcons.FolderEmptyIcon); GUI.color = previousGUIColor; }
private static void OnHierarchyWindowItemOnGUI(int instanceID, Rect position) { sCurrentIndentAmount = (int)((position.x / kIndentWidth) - 1); GameObject gameObject = (GameObject)EditorUtility.InstanceIDToObject(instanceID); if (gameObject == null) { return; } sCurrentObjectData = GrendelHierarchy.EnsureObjectHasGrendelData(gameObject); if (sCurrentObjectData == null) { return; } sCurrentItemPosition = new Rect(position); sCurrentTransform = gameObject.transform; sCurrentParents = new List <Transform>(gameObject.GetComponentsInParent <Transform>(true)); if (sCurrentParents.Count > 0 && sCurrentParents.Contains(gameObject.transform)) { sCurrentParents.Remove(gameObject.transform); } sCurrentChildCount = gameObject.transform.childCount; sCurrentParentCount = sCurrentParents.Count; if (sPreviousItemPosition.y > position.y) { //we're back at the top of the hierarchy sTotalCurrentObjectCount = sCurrentObjectIndex; sCurrentObjectIndex = 0; RefreshLayerVisibility(); } GrendelFolderComponent folderComponent = gameObject.GetComponent <GrendelFolderComponent>(); if (folderComponent != null && !IsGameObjectBeingRenamed(gameObject)) { GrendelFolder.DrawFolder(position, folderComponent, CurrentRowColor); } ColorNextRow(position); //if (gameObject.transform.parent != null) //{ // GUI.Label(position, "------------------" + EditorWindow.GetWindowWithRect<EditorWindow>(sCurrentItemPosition).ToString()); //} if (GrendelPreferencesHierarchy.sTreeViewEnabled.BoolValue) { GrendelHierarchyTreeView.DrawTreeBranch(gameObject, position, sCurrentIndentAmount, sPreviousIndentAmount); } Rect previewPosition = new Rect(position); previewPosition.x -= kIconWidth; previewPosition.width = kIconWidth; GrendelHierarchyObjectPreview.DrawPreview(gameObject, previewPosition, position, folderComponent == null); Rect sideBarPosition = new Rect(position); sideBarPosition.width += (sCurrentIndentAmount + 1) * kIndentWidth; DrawSidebar(sideBarPosition); Rect iconPosition = new Rect(position); iconPosition.width = kIconWidth; iconPosition.x = (position.width - kIconWidth) + kIconRightMargin; iconPosition.x += (kIndentWidth * sCurrentIndentAmount); GrendelLockButton.DrawLockButton(sCurrentObjectData, iconPosition); iconPosition.x -= (kIconWidth + kIconBufferWidth); GrendelHideButton.DrawHideButton(sCurrentObjectData, iconPosition); Rect layerPreviewPosition = new Rect(iconPosition); if (GrendelPreferencesHierarchy.sLayerPreviewEnabled.BoolValue) { layerPreviewPosition.x -= (kIconWidth * 2) + (kIconBufferWidth * 2); layerPreviewPosition.width = kIconWidth * 2; GrendelHierarchyLayerPreview.DrawLayerPreview(sCurrentObjectData, layerPreviewPosition); } if (GrendelPreferencesHierarchy.sComponentPreviewEnabled.BoolValue) { iconPosition = new Rect(layerPreviewPosition); iconPosition.x -= (kIconWidth) + (kIconBufferWidth); iconPosition.width = kIconWidth; GrendelHierarchyObjectPreview.DrawTypeIcon(iconPosition, gameObject, folderComponent); } sPreviousIndentAmount = sCurrentIndentAmount; sPreviousItemPosition = new Rect(position); sCurrentObjectIndex++; }