Beispiel #1
0
 public static IHierarchyProperty CreateHierarchyPropertyForFilter(FilteredHierarchy filteredHierarchy)
 {
     if (filteredHierarchy.searchFilter.GetState() != SearchFilter.State.EmptySearchFilter)
     {
         return(new FilteredHierarchyProperty(filteredHierarchy));
     }
     return(new HierarchyProperty(filteredHierarchy.hierarchyType));
 }
 public static IHierarchyProperty CreateHierarchyPropertyForFilter(FilteredHierarchy filteredHierarchy)
 {
     if (filteredHierarchy.searchFilter.GetState() != SearchFilter.State.EmptySearchFilter)
     {
         return new FilteredHierarchyProperty(filteredHierarchy);
     }
     return new HierarchyProperty(filteredHierarchy.hierarchyType);
 }
Beispiel #3
0
        public static IHierarchyProperty CreateHierarchyPropertyForFilter(FilteredHierarchy filteredHierarchy)
        {
            IHierarchyProperty result;

            if (filteredHierarchy.searchFilter.GetState() != SearchFilter.State.EmptySearchFilter)
            {
                result = new FilteredHierarchyProperty(filteredHierarchy);
            }
            else
            {
                result = new HierarchyProperty(filteredHierarchy.hierarchyType, false);
            }
            return(result);
        }
 private void CopyPropertyData(ref FilteredHierarchy.FilterResult result, HierarchyProperty property)
 {
   if (result == null)
     result = new FilteredHierarchy.FilterResult();
   result.instanceID = property.instanceID;
   result.name = property.name;
   result.hasChildren = property.hasChildren;
   result.colorCode = property.colorCode;
   result.isMainRepresentation = property.isMainRepresentation;
   result.hasFullPreviewImage = property.hasFullPreviewImage;
   result.iconDrawStyle = property.iconDrawStyle;
   result.isFolder = property.isFolder;
   result.type = this.hierarchyType;
   if (!property.isMainRepresentation)
     result.icon = property.icon;
   else if (property.isFolder && !property.hasChildren)
     result.icon = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);
   else
     result.icon = (Texture2D) null;
 }
 public static void DrawIconAndLabel(Rect rect, FilteredHierarchy.FilterResult filterItem, string label, Texture2D icon, bool selected, bool focus)
 {
   float num = !ObjectListArea.s_VCEnabled ? 0.0f : 14f;
   ObjectListArea.s_Styles.resultsLabel.padding.left = (int) ((double) num + 16.0 + 2.0);
   ObjectListArea.s_Styles.resultsLabel.Draw(rect, label, false, false, selected, focus);
   Rect position = rect;
   position.width = 16f;
   position.x += num * 0.5f;
   if ((UnityEngine.Object) icon != (UnityEngine.Object) null)
     GUI.DrawTexture(position, (Texture) icon);
   if (filterItem == null || !filterItem.isMainRepresentation)
     return;
   Rect drawRect = rect;
   drawRect.width = num + 16f;
   ProjectHooks.OnProjectWindowItem(filterItem.guid, drawRect);
 }
 public void ShowObjectsInList(int[] instanceIDs)
 {
   this.m_FilteredHierarchy = new FilteredHierarchy(HierarchyType.Assets);
   this.m_FilteredHierarchy.SetResults(instanceIDs);
 }
 private void RefreshHierarchy(HierarchyType hierarchyType, SearchFilter searchFilter, bool foldersFirst)
 {
   this.m_FilteredHierarchy = new FilteredHierarchy(hierarchyType);
   this.m_FilteredHierarchy.foldersFirst = foldersFirst;
   this.m_FilteredHierarchy.searchFilter = searchFilter;
   this.m_FilteredHierarchy.RefreshVisibleItems(this.m_Owner.m_State.m_ExpandedInstanceIDs);
 }
 private void DrawItem(Rect position, FilteredHierarchy.FilterResult filterItem, BuiltinResource builtinResource, bool isFolderBrowsing)
 {
   Event current = Event.current;
   Rect selectionRect = position;
   int num1 = 0;
   bool flag1 = false;
   if (filterItem != null)
   {
     num1 = filterItem.instanceID;
     flag1 = filterItem.hasChildren && !filterItem.isFolder && isFolderBrowsing;
   }
   else if (builtinResource != null)
     num1 = builtinResource.m_InstanceID;
   int idFromInstanceId = ObjectListArea.LocalGroup.GetControlIDFromInstanceID(num1);
   bool flag2 = !this.m_Owner.allowDragging ? this.m_Owner.IsSelected(num1) : (this.m_DragSelection.Count <= 0 ? this.m_Owner.IsSelected(num1) : this.m_DragSelection.Contains(num1));
   if (flag2 && num1 == this.m_Owner.m_State.m_LastClickedInstanceID)
     this.m_LastClickedDrawTime = EditorApplication.timeSinceStartup;
   Rect position1 = new Rect(position.x + 2f, position.y, 16f, 16f);
   if (flag1 && !this.ListMode)
   {
     float num2 = position.height / 128f;
     float width = 28f * num2;
     float height = 32f * num2;
     position1 = new Rect(position.xMax - width * 0.5f, (float) ((double) position.y + ((double) position.height - (double) ObjectListArea.s_Styles.resultsGridLabel.fixedHeight) * 0.5 - (double) width * 0.5), width, height);
   }
   bool flag3 = false;
   if (flag2 && current.type == EventType.KeyDown && this.m_Owner.HasFocus())
   {
     switch (current.keyCode)
     {
       case KeyCode.RightArrow:
         if (this.ListMode || this.m_Owner.IsPreviewIconExpansionModifierPressed())
         {
           if (!this.IsExpanded(num1))
             flag3 = true;
           current.Use();
           break;
         }
         break;
       case KeyCode.LeftArrow:
         if (this.ListMode || this.m_Owner.IsPreviewIconExpansionModifierPressed())
         {
           if (this.IsExpanded(num1))
             flag3 = true;
           else
             this.SelectAndFrameParentOf(num1);
           current.Use();
           break;
         }
         break;
     }
   }
   if (flag1 && current.type == EventType.MouseDown && (current.button == 0 && position1.Contains(current.mousePosition)))
     flag3 = true;
   if (flag3)
   {
     bool expanded = !this.IsExpanded(num1);
     if (expanded)
       this.m_ItemFader.Start(this.m_FilteredHierarchy.GetSubAssetInstanceIDs(num1));
     this.ChangeExpandedState(num1, expanded);
     current.Use();
     GUIUtility.ExitGUI();
   }
   bool flag4 = this.IsRenaming(num1);
   Rect position2 = position;
   if (!this.ListMode)
     position2 = new Rect(position.x, position.yMax + 1f - ObjectListArea.s_Styles.resultsGridLabel.fixedHeight, position.width - 1f, ObjectListArea.s_Styles.resultsGridLabel.fixedHeight);
   int num3 = !Provider.isActive || !this.ListMode ? 0 : 14;
   float x = 16f;
   if (this.ListMode)
   {
     selectionRect.x = 16f;
     if (filterItem != null && !filterItem.isMainRepresentation && isFolderBrowsing)
     {
       x = 28f;
       selectionRect.x = (float) (28.0 + (double) num3 * 0.5);
     }
     selectionRect.width -= selectionRect.x;
   }
   if (Event.current.type == EventType.Repaint)
   {
     if (this.m_DropTargetControlID == idFromInstanceId && !position.Contains(current.mousePosition))
       this.m_DropTargetControlID = 0;
     bool flag5 = idFromInstanceId == this.m_DropTargetControlID && this.m_DragSelection.IndexOf(this.m_DropTargetControlID) == -1;
     string str = filterItem == null ? builtinResource.m_Name : filterItem.name;
     if (this.ListMode)
     {
       if (flag4)
       {
         flag2 = false;
         str = string.Empty;
       }
       position.width = Mathf.Max(position.width, 500f);
       this.m_Content.text = str;
       this.m_Content.image = (Texture) null;
       Texture2D icon = filterItem == null ? AssetPreview.GetAssetPreview(num1, this.m_Owner.GetAssetPreviewManagerID()) : filterItem.icon;
       if ((UnityEngine.Object) icon == (UnityEngine.Object) null && (UnityEngine.Object) this.m_Owner.GetCreateAssetUtility().icon != (UnityEngine.Object) null)
         icon = this.m_Owner.GetCreateAssetUtility().icon;
       if (flag2)
         ObjectListArea.s_Styles.resultsLabel.Draw(position, GUIContent.none, false, false, flag2, this.m_Owner.HasFocus());
       if (flag5)
         ObjectListArea.s_Styles.resultsLabel.Draw(position, GUIContent.none, true, true, false, false);
       ObjectListArea.LocalGroup.DrawIconAndLabel(new Rect(x, position.y, position.width - x, position.height), filterItem, str, icon, flag2, this.m_Owner.HasFocus());
       if (flag1)
         ObjectListArea.s_Styles.groupFoldout.Draw(position1, !this.ListMode, !this.ListMode, this.IsExpanded(num1), false);
     }
     else
     {
       bool flag6 = false;
       if (this.m_Owner.GetCreateAssetUtility().instanceID == num1 && (UnityEngine.Object) this.m_Owner.GetCreateAssetUtility().icon != (UnityEngine.Object) null)
       {
         this.m_Content.image = (Texture) this.m_Owner.GetCreateAssetUtility().icon;
       }
       else
       {
         this.m_Content.image = (Texture) AssetPreview.GetAssetPreview(num1, this.m_Owner.GetAssetPreviewManagerID());
         if ((UnityEngine.Object) this.m_Content.image != (UnityEngine.Object) null)
           flag6 = true;
         if (filterItem != null)
         {
           if ((UnityEngine.Object) this.m_Content.image == (UnityEngine.Object) null)
             this.m_Content.image = (Texture) filterItem.icon;
           if (isFolderBrowsing && !filterItem.isMainRepresentation)
             flag6 = false;
         }
       }
       float num2 = !flag6 ? 0.0f : 2f;
       position.height -= ObjectListArea.s_Styles.resultsGridLabel.fixedHeight + 2f * num2;
       position.y += num2;
       Rect rect = !((UnityEngine.Object) this.m_Content.image == (UnityEngine.Object) null) ? ObjectListArea.LocalGroup.ActualImageDrawPosition(position, (float) this.m_Content.image.width, (float) this.m_Content.image.height) : new Rect();
       this.m_Content.text = (string) null;
       float a = 1f;
       if (filterItem != null)
       {
         this.AddDirtyStateFor(filterItem.instanceID);
         if (!filterItem.isMainRepresentation && isFolderBrowsing)
         {
           position.x += 4f;
           position.y += 4f;
           position.width -= 8f;
           position.height -= 8f;
           rect = !((UnityEngine.Object) this.m_Content.image == (UnityEngine.Object) null) ? ObjectListArea.LocalGroup.ActualImageDrawPosition(position, (float) this.m_Content.image.width, (float) this.m_Content.image.height) : new Rect();
           a = this.m_ItemFader.GetAlpha(filterItem.instanceID);
           if ((double) a < 1.0)
             this.m_Owner.Repaint();
         }
         if (flag6 && filterItem.iconDrawStyle == IconDrawStyle.NonTexture)
           ObjectListArea.s_Styles.previewBg.Draw(rect, GUIContent.none, false, false, false, false);
       }
       Color color1 = GUI.color;
       if (flag2)
         GUI.color *= new Color(0.85f, 0.9f, 1f);
       if ((UnityEngine.Object) this.m_Content.image != (UnityEngine.Object) null)
       {
         Color color2 = GUI.color;
         if ((double) a < 1.0)
           GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, a);
         ObjectListArea.s_Styles.resultsGrid.Draw(rect, this.m_Content, false, false, flag2, this.m_Owner.HasFocus());
         if ((double) a < 1.0)
           GUI.color = color2;
       }
       if (flag2)
         GUI.color = color1;
       if (flag6)
       {
         Rect position3 = new RectOffset(1, 1, 1, 1).Remove(ObjectListArea.s_Styles.textureIconDropShadow.border.Add(rect));
         ObjectListArea.s_Styles.textureIconDropShadow.Draw(position3, GUIContent.none, false, false, flag2 || flag5, this.m_Owner.HasFocus() || flag4 || flag5);
       }
       if (!flag4)
       {
         if (flag5)
           ObjectListArea.s_Styles.resultsLabel.Draw(new Rect(position2.x - 10f, position2.y, position2.width + 20f, position2.height), GUIContent.none, true, true, false, false);
         string croppedLabelText = this.m_Owner.GetCroppedLabelText(num1, str, position.width);
         ObjectListArea.s_Styles.resultsGridLabel.Draw(position2, croppedLabelText, false, false, flag2, this.m_Owner.HasFocus());
       }
       if (flag1)
         ObjectListArea.s_Styles.subAssetExpandButton.Draw(position1, !this.ListMode, !this.ListMode, this.IsExpanded(num1), false);
       if (filterItem != null && filterItem.isMainRepresentation)
         ProjectHooks.OnProjectWindowItem(filterItem.guid, position);
     }
   }
   if (flag4)
   {
     if (this.ListMode)
     {
       float num2 = (float) (num3 + 16);
       position2.x = selectionRect.x + num2;
       position2.width -= position2.x;
     }
     else
     {
       position2.x -= 4f;
       position2.width += 8f;
     }
     this.m_Owner.GetRenameOverlay().editFieldRect = position2;
     this.m_Owner.HandleRenameOverlay();
   }
   if (EditorApplication.projectWindowItemOnGUI != null && filterItem != null && this.m_Owner.allowUserRenderingHook)
     EditorApplication.projectWindowItemOnGUI(filterItem.guid, selectionRect);
   if (this.m_Owner.allowDragging)
     this.HandleMouseWithDragging(num1, idFromInstanceId, position);
   else
     this.HandleMouseWithoutDragging(num1, idFromInstanceId, position);
 }
Beispiel #9
0
 public FilteredHierarchyProperty(FilteredHierarchy filter)
 {
     this.m_Hierarchy = filter;
 }
 public FilteredHierarchyProperty(FilteredHierarchy filter)
 {
   this.m_Hierarchy = filter;
 }
			public static void DrawIconAndLabel(Rect rect, FilteredHierarchy.FilterResult filterItem, string label, Texture2D icon, bool selected, bool focus)
			{
				float num = (!ObjectListArea.s_VCEnabled) ? 0f : 14f;
				ObjectListArea.s_Styles.resultsLabel.padding.left = (int)(num + 16f + 2f);
				ObjectListArea.s_Styles.resultsLabel.Draw(rect, label, false, false, selected, focus);
				Rect position = rect;
				position.width = 16f;
				position.x += num * 0.5f;
				if (icon != null)
				{
					GUI.DrawTexture(position, icon);
				}
				if (filterItem != null && filterItem.isMainRepresentation)
				{
					Rect drawRect = rect;
					drawRect.width = num + 16f;
					ProjectHooks.OnProjectWindowItem(filterItem.guid, drawRect);
				}
			}
			private void DrawItem(Rect position, FilteredHierarchy.FilterResult filterItem, BuiltinResource builtinResource, bool isFolderBrowsing)
			{
				Event current = Event.current;
				Rect selectionRect = position;
				int num = 0;
				bool flag = false;
				if (filterItem != null)
				{
					num = filterItem.instanceID;
					flag = (filterItem.hasChildren && !filterItem.isFolder && isFolderBrowsing);
				}
				else
				{
					if (builtinResource != null)
					{
						num = builtinResource.m_InstanceID;
					}
				}
				int controlIDFromInstanceID = ObjectListArea.LocalGroup.GetControlIDFromInstanceID(num);
				bool flag2;
				if (this.m_Owner.allowDragging)
				{
					flag2 = ((this.m_DragSelection.Count <= 0) ? this.m_Owner.IsSelected(num) : this.m_DragSelection.Contains(num));
				}
				else
				{
					flag2 = this.m_Owner.IsSelected(num);
				}
				if (flag2 && num == this.m_Owner.m_State.m_LastClickedInstanceID)
				{
					this.m_LastClickedDrawTime = EditorApplication.timeSinceStartup;
				}
				Rect position2 = new Rect(position.x + 2f, position.y, 16f, 16f);
				if (flag && !this.ListMode)
				{
					float num2 = position.height / 128f;
					float num3 = 28f * num2;
					float height = 32f * num2;
					position2 = new Rect(position.xMax - num3 * 0.5f, position.y + (position.height - ObjectListArea.s_Styles.resultsGridLabel.fixedHeight) * 0.5f - num3 * 0.5f, num3, height);
				}
				bool flag3 = false;
				if (flag2 && current.type == EventType.KeyDown && this.m_Owner.HasFocus())
				{
					KeyCode keyCode = current.keyCode;
					if (keyCode != KeyCode.RightArrow)
					{
						if (keyCode == KeyCode.LeftArrow)
						{
							if (this.ListMode || this.m_Owner.IsPreviewIconExpansionModifierPressed())
							{
								if (this.IsExpanded(num))
								{
									flag3 = true;
								}
								else
								{
									this.SelectAndFrameParentOf(num);
								}
								current.Use();
							}
						}
					}
					else
					{
						if (this.ListMode || this.m_Owner.IsPreviewIconExpansionModifierPressed())
						{
							if (!this.IsExpanded(num))
							{
								flag3 = true;
							}
							current.Use();
						}
					}
				}
				if (flag && current.type == EventType.MouseDown && current.button == 0 && position2.Contains(current.mousePosition))
				{
					flag3 = true;
				}
				if (flag3)
				{
					bool flag4 = !this.IsExpanded(num);
					if (flag4)
					{
						this.m_ItemFader.Start(this.m_FilteredHierarchy.GetSubAssetInstanceIDs(num));
					}
					this.ChangeExpandedState(num, flag4);
					current.Use();
					GUIUtility.ExitGUI();
				}
				bool flag5 = this.IsRenaming(num);
				Rect rect = position;
				if (!this.ListMode)
				{
					rect = new Rect(position.x, position.yMax + 1f - ObjectListArea.s_Styles.resultsGridLabel.fixedHeight, position.width - 1f, ObjectListArea.s_Styles.resultsGridLabel.fixedHeight);
				}
				int num4 = (!Provider.isActive || !this.ListMode) ? 0 : 14;
				float num5 = 16f;
				if (this.ListMode)
				{
					selectionRect.x = 16f;
					if (filterItem != null && !filterItem.isMainRepresentation && isFolderBrowsing)
					{
						num5 = 28f;
						selectionRect.x = 28f + (float)num4 * 0.5f;
					}
					selectionRect.width -= selectionRect.x;
				}
				if (Event.current.type == EventType.Repaint)
				{
					if (this.m_DropTargetControlID == controlIDFromInstanceID && !position.Contains(current.mousePosition))
					{
						this.m_DropTargetControlID = 0;
					}
					bool flag6 = controlIDFromInstanceID == this.m_DropTargetControlID;
					string text = (filterItem == null) ? builtinResource.m_Name : filterItem.name;
					if (this.ListMode)
					{
						if (flag5)
						{
							flag2 = false;
							text = string.Empty;
						}
						position.width = Mathf.Max(position.width, 500f);
						this.m_Content.text = text;
						this.m_Content.image = null;
						Texture2D texture2D = (filterItem == null) ? AssetPreview.GetAssetPreview(num, this.m_Owner.GetAssetPreviewManagerID()) : filterItem.icon;
						if (texture2D == null && this.m_Owner.GetCreateAssetUtility().icon != null)
						{
							texture2D = this.m_Owner.GetCreateAssetUtility().icon;
						}
						if (flag2)
						{
							ObjectListArea.s_Styles.resultsLabel.Draw(position, GUIContent.none, false, false, flag2, this.m_Owner.HasFocus());
						}
						if (flag6)
						{
							ObjectListArea.s_Styles.resultsLabel.Draw(position, GUIContent.none, true, true, false, false);
						}
						ObjectListArea.LocalGroup.DrawIconAndLabel(new Rect(num5, position.y, position.width - num5, position.height), filterItem, text, texture2D, flag2, this.m_Owner.HasFocus());
						if (flag)
						{
							ObjectListArea.s_Styles.groupFoldout.Draw(position2, !this.ListMode, !this.ListMode, this.IsExpanded(num), false);
						}
					}
					else
					{
						bool flag7 = false;
						if (this.m_Owner.GetCreateAssetUtility().instanceID == num && this.m_Owner.GetCreateAssetUtility().icon != null)
						{
							this.m_Content.image = this.m_Owner.GetCreateAssetUtility().icon;
						}
						else
						{
							this.m_Content.image = AssetPreview.GetAssetPreview(num, this.m_Owner.GetAssetPreviewManagerID());
							if (this.m_Content.image != null)
							{
								flag7 = true;
							}
							if (filterItem != null)
							{
								if (this.m_Content.image == null)
								{
									this.m_Content.image = filterItem.icon;
								}
								if (isFolderBrowsing && !filterItem.isMainRepresentation)
								{
									flag7 = false;
								}
							}
						}
						float num6 = (!flag7) ? 0f : 2f;
						position.height -= ObjectListArea.s_Styles.resultsGridLabel.fixedHeight + 2f * num6;
						position.y += num6;
						Rect rect2 = (!(this.m_Content.image == null)) ? ObjectListArea.LocalGroup.ActualImageDrawPosition(position, (float)this.m_Content.image.width, (float)this.m_Content.image.height) : default(Rect);
						this.m_Content.text = null;
						float num7 = 1f;
						if (filterItem != null)
						{
							this.AddDirtyStateFor(filterItem.instanceID);
							if (!filterItem.isMainRepresentation && isFolderBrowsing)
							{
								position.x += 4f;
								position.y += 4f;
								position.width -= 8f;
								position.height -= 8f;
								rect2 = ((!(this.m_Content.image == null)) ? ObjectListArea.LocalGroup.ActualImageDrawPosition(position, (float)this.m_Content.image.width, (float)this.m_Content.image.height) : default(Rect));
								num7 = this.m_ItemFader.GetAlpha(filterItem.instanceID);
								if (num7 < 1f)
								{
									this.m_Owner.Repaint();
								}
							}
							if (flag7 && filterItem.iconDrawStyle == IconDrawStyle.NonTexture)
							{
								ObjectListArea.s_Styles.previewBg.Draw(rect2, GUIContent.none, false, false, false, false);
							}
						}
						Color color = GUI.color;
						if (flag2)
						{
							GUI.color *= new Color(0.85f, 0.9f, 1f);
						}
						if (this.m_Content.image != null)
						{
							Color color2 = GUI.color;
							if (num7 < 1f)
							{
								GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, num7);
							}
							ObjectListArea.s_Styles.resultsGrid.Draw(rect2, this.m_Content, false, false, flag2, this.m_Owner.HasFocus());
							if (num7 < 1f)
							{
								GUI.color = color2;
							}
						}
						if (flag2)
						{
							GUI.color = color;
						}
						if (flag7)
						{
							Rect position3 = new RectOffset(1, 1, 1, 1).Remove(ObjectListArea.s_Styles.textureIconDropShadow.border.Add(rect2));
							ObjectListArea.s_Styles.textureIconDropShadow.Draw(position3, GUIContent.none, false, false, flag2 || flag6, this.m_Owner.HasFocus() || flag5 || flag6);
						}
						if (!flag5)
						{
							text = this.m_Owner.GetCroppedLabelText(num, text, position.width);
							ObjectListArea.s_Styles.resultsGridLabel.Draw(rect, text, false, false, flag2, this.m_Owner.HasFocus());
						}
						if (flag)
						{
							ObjectListArea.s_Styles.subAssetExpandButton.Draw(position2, !this.ListMode, !this.ListMode, this.IsExpanded(num), false);
						}
						if (filterItem != null && filterItem.isMainRepresentation)
						{
							ProjectHooks.OnProjectWindowItem(filterItem.guid, position);
						}
					}
				}
				if (flag5)
				{
					if (this.ListMode)
					{
						float num8 = (float)(num4 + 16);
						rect.x = selectionRect.x + num8;
						rect.width -= rect.x;
					}
					else
					{
						rect.x -= 4f;
						rect.width += 8f;
					}
					this.m_Owner.GetRenameOverlay().editFieldRect = rect;
					this.m_Owner.HandleRenameOverlay();
				}
				if (EditorApplication.projectWindowItemOnGUI != null && filterItem != null && this.m_Owner.allowUserRenderingHook)
				{
					EditorApplication.projectWindowItemOnGUI(filterItem.guid, selectionRect);
				}
				if (this.m_Owner.allowDragging)
				{
					this.HandleMouseWithDragging(num, controlIDFromInstanceID, position);
				}
				else
				{
					this.HandleMouseWithoutDragging(num, controlIDFromInstanceID, position);
				}
			}