Find() private method

private Find ( int instanceID, int expanded ) : bool
instanceID int
expanded int
return bool
		public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);
			if (parentItem == null || targetItem == null)
			{
				return InternalEditorUtility.HierarchyWindowDrag(null, perform, InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
			}
			if (this.allowDragBetween)
			{
				if (dropPos == TreeViewDragging.DropPosition.Above || targetItem == null || !hierarchyProperty.Find(targetItem.id, null))
				{
					hierarchyProperty = null;
				}
			}
			else
			{
				if (dropPos == TreeViewDragging.DropPosition.Above || parentItem == null || !hierarchyProperty.Find(parentItem.id, null))
				{
					hierarchyProperty = null;
				}
			}
			InternalEditorUtility.HierarchyDropMode hierarchyDropMode = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal;
			if (this.allowDragBetween)
			{
				hierarchyDropMode = ((dropPos != TreeViewDragging.DropPosition.Upon) ? InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween : InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
			}
			if (parentItem != null && parentItem == targetItem && dropPos != TreeViewDragging.DropPosition.Above)
			{
				hierarchyDropMode |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent;
			}
			return InternalEditorUtility.HierarchyWindowDrag(hierarchyProperty, perform, hierarchyDropMode);
		}
 public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
 {
     HierarchyProperty property = new HierarchyProperty(HierarchyType.GameObjects);
     if ((parentItem == null) || (targetItem == null))
     {
         return InternalEditorUtility.HierarchyWindowDrag(null, perform, InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
     }
     if (this.allowDragBetween)
     {
         if (((dropPos == TreeViewDragging.DropPosition.Above) || (targetItem == null)) || !property.Find(targetItem.id, null))
         {
             property = null;
         }
     }
     else if (((dropPos == TreeViewDragging.DropPosition.Above) || (parentItem == null)) || !property.Find(parentItem.id, null))
     {
         property = null;
     }
     InternalEditorUtility.HierarchyDropMode kHierarchyDragNormal = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal;
     if (this.allowDragBetween)
     {
         kHierarchyDragNormal = (dropPos != TreeViewDragging.DropPosition.Upon) ? InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween : InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon;
     }
     if (((parentItem != null) && (parentItem == targetItem)) && (dropPos != TreeViewDragging.DropPosition.Above))
     {
         kHierarchyDragNormal |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent;
     }
     return InternalEditorUtility.HierarchyWindowDrag(property, perform, kHierarchyDragNormal);
 }
 public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
 {
   HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
   if (parentItem == null || !property.Find(parentItem.id, (int[]) null))
     property = (HierarchyProperty) null;
   return InternalEditorUtility.ProjectWindowDrag(property, perform);
 }
 public override void FetchData()
 {
     Profiler.BeginSample("SceneHierarchyWindow.FetchData");
     int depth = 0;
     double timeSinceStartup = EditorApplication.timeSinceStartup;
     HierarchyProperty property = new HierarchyProperty(HierarchyType.GameObjects);
     property.Reset();
     property.alphaSorted = this.IsUsingAlphaSort();
     if (this.m_RootInstanceID != 0)
     {
         bool flag = property.Find(this.m_RootInstanceID, null);
         string displayName = !flag ? "RootOfSceneHierarchy" : property.name;
         base.m_RootItem = new GameObjectTreeViewItem(this.m_RootInstanceID, depth, null, displayName);
         if (!flag)
         {
             Debug.LogError("Root gameobject with id " + this.m_RootInstanceID + " not found!!");
         }
     }
     else
     {
         base.m_RootItem = new GameObjectTreeViewItem(this.m_RootInstanceID, depth, null, "RootOfSceneHierarchy");
     }
     if (!base.showRootNode)
     {
         this.SetExpanded(base.m_RootItem, true);
     }
     bool hasSearchString = !string.IsNullOrEmpty(this.m_SearchString);
     if (hasSearchString)
     {
         property.SetSearchFilter(this.m_SearchString, this.m_SearchMode);
     }
     base.m_VisibleRows = this.CalcVisibleItems(property, hasSearchString);
     this.m_NeedsChildParentReferenceSetup = true;
     base.m_NeedRefreshVisibleFolders = false;
     if ((this.sortingState.sortingObject != null) && this.sortingState.implementsCompare)
     {
         this.SortVisibleRows();
     }
     double num3 = EditorApplication.timeSinceStartup;
     double num4 = num3 - timeSinceStartup;
     double num5 = num3 - this.m_LastFetchTime;
     if ((num5 > 0.1) && (num4 > 0.05))
     {
         this.m_DelayedFetches++;
     }
     else
     {
         this.m_DelayedFetches = 0;
     }
     this.m_LastFetchTime = timeSinceStartup;
     base.m_TreeView.SetSelection(Selection.instanceIDs, false);
     if (SceneHierarchyWindow.s_Debug)
     {
         Debug.Log(string.Concat(new object[] { "Fetch time: ", num4 * 1000.0, " ms, alphaSort = ", this.IsUsingAlphaSort() }));
     }
     Profiler.EndSample();
 }
 public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
 {
     if (targetItem == null)
     {
         return DragAndDropVisualMode.None;
     }
     object genericData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData);
     if (genericData != null)
     {
         int instanceID = (int) genericData;
         if (!(targetItem is SearchFilterTreeItem) || !(parentItem is SearchFilterTreeItem))
         {
             return DragAndDropVisualMode.None;
         }
         bool flag = SavedSearchFilters.CanMoveSavedFilter(instanceID, parentItem.id, targetItem.id, true);
         if (flag && perform)
         {
             SavedSearchFilters.MoveSavedFilter(instanceID, parentItem.id, targetItem.id, true);
         }
         return (!flag ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy);
     }
     if (!(targetItem is SearchFilterTreeItem) || !(parentItem is SearchFilterTreeItem))
     {
         return base.DoDrag(parentItem, targetItem, perform, dropPos);
     }
     string str = DragAndDrop.GetGenericData(ProjectWindowUtil.k_IsFolderGenericData) as string;
     if (!(str == "isFolder"))
     {
         return DragAndDropVisualMode.None;
     }
     if (perform)
     {
         UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
         if (objectReferences.Length > 0)
         {
             HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
             if (property.Find(objectReferences[0].GetInstanceID(), null))
             {
                 SearchFilter filter = new SearchFilter();
                 string assetPath = AssetDatabase.GetAssetPath(property.instanceID);
                 if (!string.IsNullOrEmpty(assetPath))
                 {
                     filter.folders = new string[] { assetPath };
                     bool addAsChild = targetItem == parentItem;
                     float listAreaGridSize = ProjectBrowserColumnOneTreeViewGUI.GetListAreaGridSize();
                     Selection.activeInstanceID = SavedSearchFilters.AddSavedFilterAfterInstanceID(property.name, filter, listAreaGridSize, targetItem.id, addAsChild);
                 }
                 else
                 {
                     Debug.Log("Could not get asset path from id " + property.name);
                 }
             }
         }
     }
     return DragAndDropVisualMode.Copy;
 }
 public void SetResults(int[] instanceIDs)
 {
   HierarchyProperty property = new HierarchyProperty(this.m_HierarchyType);
   property.Reset();
   Array.Resize<FilteredHierarchy.FilterResult>(ref this.m_Results, instanceIDs.Length);
   for (int index = 0; index < instanceIDs.Length; ++index)
   {
     if (property.Find(instanceIDs[index], (int[]) null))
       this.CopyPropertyData(ref this.m_Results[index], property);
   }
 }
        private void DoSelectionChange()
        {
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            List <string>     stringList        = new List <string>(Selection.objects.Length);

            foreach (UnityEngine.Object @object in Selection.objects)
            {
                if (hierarchyProperty.Find(@object.GetInstanceID(), (int[])null))
                {
                    stringList.Add(hierarchyProperty.guid);
                }
            }
            for (int index = 0; index < this.downloadConflicts.Length; ++index)
            {
                this.selectedLV1Items[index] = stringList.Contains(this.downloadConflicts[index]);
            }
            for (int index = 0; index < this.nameConflicts.Length; ++index)
            {
                this.selectedLV2Items[index] = stringList.Contains(this.nameConflicts[index]);
            }
            this.lv1HasSelection   = this.HasTrue(ref this.selectedLV1Items);
            this.lv2HasSelection   = this.HasTrue(ref this.selectedLV2Items);
            this.enableMergeButton = this.AtLeastOneSelectedAssetCanBeMerged();
        }
        private void DoSelectionChange()
        {
            HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
            List <string>     list     = new List <string>(Selection.objects.Length);

            foreach (UnityEngine.Object obj2 in Selection.objects)
            {
                if (property.Find(obj2.GetInstanceID(), null))
                {
                    list.Add(property.guid);
                }
            }
            for (int i = 0; i < this.downloadConflicts.Length; i++)
            {
                this.selectedLV1Items[i] = list.Contains(this.downloadConflicts[i]);
            }
            for (int j = 0; j < this.nameConflicts.Length; j++)
            {
                this.selectedLV2Items[j] = list.Contains(this.nameConflicts[j]);
            }
            this.lv1HasSelection   = this.HasTrue(ref this.selectedLV1Items);
            this.lv2HasSelection   = this.HasTrue(ref this.selectedLV2Items);
            this.enableMergeButton = this.AtLeastOneSelectedAssetCanBeMerged();
        }
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            if (targetItem == null)
            {
                return(DragAndDropVisualMode.None);
            }
            object genericData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData);

            if (genericData != null)
            {
                int instanceID = (int)genericData;
                if (targetItem is SearchFilterTreeItem && parentItem is SearchFilterTreeItem)
                {
                    bool flag = SavedSearchFilters.CanMoveSavedFilter(instanceID, parentItem.id, targetItem.id, true);
                    if (flag && perform)
                    {
                        SavedSearchFilters.MoveSavedFilter(instanceID, parentItem.id, targetItem.id, true);
                    }
                    return((!flag) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy);
                }
                return(DragAndDropVisualMode.None);
            }
            else
            {
                if (!(targetItem is SearchFilterTreeItem) || !(parentItem is SearchFilterTreeItem))
                {
                    return(base.DoDrag(parentItem, targetItem, perform, dropPos));
                }
                string a = DragAndDrop.GetGenericData(ProjectWindowUtil.k_IsFolderGenericData) as string;
                if (a == "isFolder")
                {
                    if (perform)
                    {
                        UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
                        if (objectReferences.Length > 0)
                        {
                            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
                            if (hierarchyProperty.Find(objectReferences[0].GetInstanceID(), null))
                            {
                                SearchFilter searchFilter = new SearchFilter();
                                string       assetPath    = AssetDatabase.GetAssetPath(hierarchyProperty.instanceID);
                                if (!string.IsNullOrEmpty(assetPath))
                                {
                                    searchFilter.folders = new string[]
                                    {
                                        assetPath
                                    };
                                    bool  addAsChild       = targetItem == parentItem;
                                    float listAreaGridSize = ProjectBrowserColumnOneTreeViewGUI.GetListAreaGridSize();
                                    int   activeInstanceID = SavedSearchFilters.AddSavedFilterAfterInstanceID(hierarchyProperty.name, searchFilter, listAreaGridSize, targetItem.id, addAsChild);
                                    Selection.activeInstanceID = activeInstanceID;
                                }
                                else
                                {
                                    Debug.Log("Could not get asset path from id " + hierarchyProperty.name);
                                }
                            }
                        }
                    }
                    return(DragAndDropVisualMode.Copy);
                }
                return(DragAndDropVisualMode.None);
            }
        }
Exemplo n.º 10
0
 public DragAndDropVisualMode DoDrag(int dragToInstanceID, bool perform)
 {
   HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
   if (!property.Find(dragToInstanceID, (int[]) null))
     property = (HierarchyProperty) null;
   return InternalEditorUtility.ProjectWindowDrag(property, perform);
 }
Exemplo n.º 11
0
		private HierarchyProperty GetLastSelected()
		{
			int num = -1;
			HierarchyProperty result = null;
			UnityEngine.Object[] objects = Selection.objects;
			for (int i = 0; i < objects.Length; i++)
			{
				UnityEngine.Object @object = objects[i];
				HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
				if (hierarchyProperty.Find(@object.GetInstanceID(), this.m_ExpandedArray) && hierarchyProperty.row > num)
				{
					num = hierarchyProperty.row;
					result = hierarchyProperty;
				}
			}
			return result;
		}
Exemplo n.º 12
0
 private void FolderBrowsing(HierarchyProperty property)
 {
     List<FilterResult> list = new List<FilterResult>();
     foreach (string str in this.m_SearchFilter.folders)
     {
         int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(str);
         if (property.Find(mainAssetInstanceID, null))
         {
             int depth = property.depth;
             int[] expanded = new int[] { mainAssetInstanceID };
             while (property.Next(expanded))
             {
                 if (property.depth <= depth)
                 {
                     break;
                 }
                 FilterResult result = new FilterResult();
                 this.CopyPropertyData(ref result, property);
                 list.Add(result);
                 if (property.hasChildren && !property.isFolder)
                 {
                     Array.Resize<int>(ref expanded, expanded.Length + 1);
                     expanded[expanded.Length - 1] = property.instanceID;
                 }
             }
         }
     }
     this.m_Results = list.ToArray();
 }
Exemplo n.º 13
0
        public override void FetchData()
        {
            // Create root Item
            int depth = 0;

            m_RootItem = new TreeViewItem(m_RootInstanceID, depth, null, CreateDisplayName(m_RootInstanceID));
            if (!showRootItem)
            {
                SetExpanded(m_RootItem, true);
            }

            // Find start Item
            var property = new HierarchyProperty(k_HierarchyType, false);

            property.Reset();
            bool found = property.Find(m_RootInstanceID, null);

            if (!found)
            {
                Debug.LogError("Root Asset with id " + m_RootInstanceID + " not found!!");
            }

            int minDepth = property.depth + (showRootItem ? 0 : 1);

            int[]     expanded        = expandedIDs.ToArray();
            Texture2D emptyFolderIcon = EditorGUIUtility.FindTexture(EditorResources.emptyFolderIconName);

            // Fetch visible items
            m_Rows = new List <TreeViewItem>();
            while (property.NextWithDepthCheck(expanded, minDepth))
            {
                if (!foldersOnly || property.isFolder)
                {
                    depth = property.depth - minDepth;
                    TreeViewItem item;
                    if (property.isFolder)
                    {
                        item = new FolderTreeItem(property.instanceID, depth, null, property.name);
                    }
                    else
                    {
                        item = new NonFolderTreeItem(property.instanceID, depth, null, property.name);
                    }

                    if (property.isFolder && !property.hasChildren)
                    {
                        item.icon = emptyFolderIcon;
                    }
                    else
                    {
                        item.icon = property.icon;
                    }

                    if (property.hasChildren)
                    {
                        item.AddChild(null); // add a dummy child in children list to ensure we show the collapse arrow (because we do not fetch data for collapsed items)
                    }
                    m_Rows.Add(item);
                }
            }

            // Setup reference between child and parent items
            TreeViewUtility.SetChildParentReferences(m_Rows, m_RootItem);

            if (foldersFirst)
            {
                FoldersFirstRecursive(m_RootItem);
                m_Rows.Clear();
                GetVisibleItemsRecursive(m_RootItem, m_Rows);
            }

            // Must be called before InitSelection (it calls GetVisibleItems)
            m_NeedRefreshRows = false;

            // We want to reset selection on copy/duplication/delete
            bool frameLastSelected = false; // use false because we might just be expanding/collapsing a Item (which would prevent collapsing a Item with a selected child)

            m_TreeView.SetSelection(Selection.instanceIDs, frameLastSelected);
        }
		private float DoSearchResultPathGUI()
		{
			if (!base.hasSearchFilter)
			{
				return 0f;
			}
			GUILayout.FlexibleSpace();
			Rect rect = EditorGUILayout.BeginVertical(EditorStyles.inspectorBig, new GUILayoutOption[0]);
			GUILayout.Label("Path:", new GUILayoutOption[0]);
			if (this.m_TreeView.HasSelection())
			{
				int instanceID = this.m_TreeView.GetSelection()[0];
				IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);
				hierarchyProperty.Find(instanceID, null);
				if (hierarchyProperty.isValid)
				{
					do
					{
						EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
						GUILayout.Label(hierarchyProperty.icon, new GUILayoutOption[0]);
						GUILayout.Label(hierarchyProperty.name, new GUILayoutOption[0]);
						GUILayout.FlexibleSpace();
						EditorGUILayout.EndHorizontal();
					}
					while (hierarchyProperty.Parent());
				}
			}
			EditorGUILayout.EndVertical();
			GUILayout.Space(0f);
			return rect.height;
		}
Exemplo n.º 15
0
 private bool FrameObject(UnityEngine.Object target)
 {
     if (target != null)
     {
         HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
         if (property.Find(target.GetInstanceID(), null))
         {
             while (property.Parent())
             {
                 this.SetExpanded(property.instanceID, true);
             }
         }
         property.Reset();
         if (property.Find(target.GetInstanceID(), this.m_ExpandedArray))
         {
             this.ScrollTo((m_RowHeight * property.row) + this.m_SpaceAtTheTop);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 16
0
		private void FolderBrowsing(HierarchyProperty property)
		{
			List<FilteredHierarchy.FilterResult> list = new List<FilteredHierarchy.FilterResult>();
			string[] folders = this.m_SearchFilter.folders;
			for (int i = 0; i < folders.Length; i++)
			{
				string assetPath = folders[i];
				int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
				if (property.Find(mainAssetInstanceID, null))
				{
					int depth = property.depth;
					int[] array = new int[]
					{
						mainAssetInstanceID
					};
					while (property.Next(array))
					{
						if (property.depth <= depth)
						{
							break;
						}
						FilteredHierarchy.FilterResult item = new FilteredHierarchy.FilterResult();
						this.CopyPropertyData(ref item, property);
						list.Add(item);
						if (property.hasChildren && !property.isFolder)
						{
							Array.Resize<int>(ref array, array.Length + 1);
							array[array.Length - 1] = property.instanceID;
						}
					}
				}
			}
			this.m_Results = list.ToArray();
		}
Exemplo n.º 17
0
 private HierarchyProperty GetFirstSelected()
 {
     int row = 0x3b9aca00;
     HierarchyProperty property = null;
     foreach (Object obj2 in Selection.objects)
     {
         HierarchyProperty property2 = new HierarchyProperty(HierarchyType.Assets);
         if (property2.Find(obj2.GetInstanceID(), this.m_ExpandedArray) && (property2.row < row))
         {
             row = property2.row;
             property = property2;
         }
     }
     return property;
 }
Exemplo n.º 18
0
		private void SearchInFolders(HierarchyProperty property)
		{
			List<FilteredHierarchy.FilterResult> list = new List<FilteredHierarchy.FilterResult>();
			string[] baseFolders = ProjectWindowUtil.GetBaseFolders(this.m_SearchFilter.folders);
			string[] array = baseFolders;
			for (int i = 0; i < array.Length; i++)
			{
				string assetPath = array[i];
				property.SetSearchFilter(new SearchFilter());
				int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
				if (property.Find(mainAssetInstanceID, null))
				{
					property.SetSearchFilter(this.m_SearchFilter);
					int depth = property.depth;
					int[] expanded = null;
					while (property.NextWithDepthCheck(expanded, depth + 1))
					{
						FilteredHierarchy.FilterResult item = new FilteredHierarchy.FilterResult();
						this.CopyPropertyData(ref item, property);
						list.Add(item);
					}
				}
			}
			this.m_Results = list.ToArray();
		}
Exemplo n.º 19
0
		public void SetResults(int[] instanceIDs)
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(this.m_HierarchyType);
			hierarchyProperty.Reset();
			Array.Resize<FilteredHierarchy.FilterResult>(ref this.m_Results, instanceIDs.Length);
			for (int i = 0; i < instanceIDs.Length; i++)
			{
				if (hierarchyProperty.Find(instanceIDs[i], null))
				{
					this.CopyPropertyData(ref this.m_Results[i], hierarchyProperty);
				}
			}
		}
Exemplo n.º 20
0
		public void BeginPing(int instanceID)
		{
			if (ObjectListArea.s_Styles == null)
			{
				ObjectListArea.s_Styles = new ObjectListArea.Styles();
			}
			int num = this.m_LocalAssets.IndexOf(instanceID);
			if (num != -1)
			{
				string text = null;
				HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
				if (hierarchyProperty.Find(instanceID, null))
				{
					text = hierarchyProperty.name;
				}
				if (text == null)
				{
					return;
				}
				this.m_Ping.m_TimeStart = Time.realtimeSinceStartup;
				this.m_Ping.m_AvailableWidth = this.m_VisibleRect.width;
				this.m_pingIndex = num;
				float num2 = (!ObjectListArea.s_VCEnabled) ? 0f : 14f;
				GUIContent gUIContent = new GUIContent((!this.m_LocalAssets.ListMode) ? this.GetCroppedLabelText(instanceID, text, (float)this.m_WidthUsedForCroppingName) : text);
				string label = gUIContent.text;
				if (this.m_LocalAssets.ListMode)
				{
					this.m_Ping.m_PingStyle = ObjectListArea.s_Styles.ping;
					Vector2 vector = this.m_Ping.m_PingStyle.CalcSize(gUIContent);
					this.m_Ping.m_ContentRect.width = vector.x + num2 + 16f;
					this.m_Ping.m_ContentRect.height = vector.y;
					this.m_LeftPaddingForPinging = ((!hierarchyProperty.isMainRepresentation) ? 28 : 16);
					FilteredHierarchy.FilterResult res = this.m_LocalAssets.LookupByInstanceID(instanceID);
					this.m_Ping.m_ContentDraw = delegate(Rect r)
					{
						ObjectListArea.LocalGroup.DrawIconAndLabel(r, res, label, hierarchyProperty.icon, false, false);
					};
				}
				else
				{
					this.m_Ping.m_PingStyle = ObjectListArea.s_Styles.miniPing;
					Vector2 vector2 = this.m_Ping.m_PingStyle.CalcSize(gUIContent);
					this.m_Ping.m_ContentRect.width = vector2.x;
					this.m_Ping.m_ContentRect.height = vector2.y;
					this.m_Ping.m_ContentDraw = delegate(Rect r)
					{
						TextAnchor alignment = ObjectListArea.s_Styles.resultsGridLabel.alignment;
						ObjectListArea.s_Styles.resultsGridLabel.alignment = TextAnchor.UpperLeft;
						ObjectListArea.s_Styles.resultsGridLabel.Draw(r, label, false, false, false, false);
						ObjectListArea.s_Styles.resultsGridLabel.alignment = alignment;
					};
				}
				Vector2 vector3 = this.CalculatePingPosition();
				this.m_Ping.m_ContentRect.x = vector3.x;
				this.m_Ping.m_ContentRect.y = vector3.y;
				this.Repaint();
			}
		}
Exemplo n.º 21
0
		private void Reveal(int instanceID)
		{
			IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			if (hierarchyProperty.Find(instanceID, null) && hierarchyProperty.Parent() && !hierarchyProperty.isFolder)
			{
				int instanceID2 = hierarchyProperty.instanceID;
				this.m_LocalAssets.ChangeExpandedState(instanceID2, true);
			}
		}
Exemplo n.º 22
0
 private void DoSelectionChange()
 {
   HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
   List<string> guids = new List<string>(Selection.objects.Length);
   foreach (UnityEngine.Object @object in Selection.objects)
   {
     if (hierarchyProperty.Find(@object.GetInstanceID(), (int[]) null))
       guids.Add(hierarchyProperty.guid);
   }
   if (this.pv1hasSelection)
     this.pv1hasSelection = ASCommitWindow.MarkSelected(this.pv1state, guids);
   if (this.pv1hasSelection)
     return;
   if (this.pv2hasSelection)
     this.pv2hasSelection = ASCommitWindow.MarkSelected(this.pv2state, guids);
   if (this.pv2hasSelection)
     return;
   this.pv1hasSelection = ASCommitWindow.MarkSelected(this.pv1state, guids);
   if (this.pv1hasSelection)
     return;
   this.pv2hasSelection = ASCommitWindow.MarkSelected(this.pv2state, guids);
 }
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);

            if (parentItem == null || targetItem == null)
            {
                return(InternalEditorUtility.HierarchyWindowDrag(null, perform, InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon));
            }
            if (this.allowDragBetween)
            {
                if (dropPos == TreeViewDragging.DropPosition.Above || targetItem == null || !hierarchyProperty.Find(targetItem.id, null))
                {
                    hierarchyProperty = null;
                }
            }
            else
            {
                if (dropPos == TreeViewDragging.DropPosition.Above || parentItem == null || !hierarchyProperty.Find(parentItem.id, null))
                {
                    hierarchyProperty = null;
                }
            }
            InternalEditorUtility.HierarchyDropMode hierarchyDropMode = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal;
            if (this.allowDragBetween)
            {
                hierarchyDropMode = ((dropPos != TreeViewDragging.DropPosition.Upon) ? InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween : InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon);
            }
            if (parentItem != null && parentItem == targetItem && dropPos != TreeViewDragging.DropPosition.Above)
            {
                hierarchyDropMode |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent;
            }
            return(InternalEditorUtility.HierarchyWindowDrag(hierarchyProperty, perform, hierarchyDropMode));
        }
		protected override HashSet<int> GetParentsAbove(int id)
		{
			HashSet<int> hashSet = new HashSet<int>();
			IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);
			if (hierarchyProperty.Find(id, null))
			{
				while (hierarchyProperty.Parent())
				{
					hashSet.Add(hierarchyProperty.instanceID);
				}
			}
			return hashSet;
		}
Exemplo n.º 25
0
 private HierarchyProperty GetLastSelected()
 {
     int row = -1;
     HierarchyProperty property = null;
     foreach (UnityEngine.Object obj2 in Selection.objects)
     {
         HierarchyProperty property2 = new HierarchyProperty(HierarchyType.Assets);
         if (property2.Find(obj2.GetInstanceID(), this.m_ExpandedArray) && (property2.row > row))
         {
             row = property2.row;
             property = property2;
         }
     }
     return property;
 }
		protected override HashSet<int> GetParentsBelow(int id)
		{
			HashSet<int> hashSet = new HashSet<int>();
			IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);
			if (hierarchyProperty.Find(id, null))
			{
				hashSet.Add(id);
				int depth = hierarchyProperty.depth;
				while (hierarchyProperty.Next(null) && hierarchyProperty.depth > depth)
				{
					if (hierarchyProperty.hasChildren)
					{
						hashSet.Add(hierarchyProperty.instanceID);
					}
				}
			}
			return hashSet;
		}
 private void DoSelectionChange()
 {
     HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
     List<string> list = new List<string>(Selection.objects.Length);
     foreach (UnityEngine.Object obj2 in Selection.objects)
     {
         if (property.Find(obj2.GetInstanceID(), null))
         {
             list.Add(property.guid);
         }
     }
     for (int i = 0; i < this.downloadConflicts.Length; i++)
     {
         this.selectedLV1Items[i] = list.Contains(this.downloadConflicts[i]);
     }
     for (int j = 0; j < this.nameConflicts.Length; j++)
     {
         this.selectedLV2Items[j] = list.Contains(this.nameConflicts[j]);
     }
     this.lv1HasSelection = this.HasTrue(ref this.selectedLV1Items);
     this.lv2HasSelection = this.HasTrue(ref this.selectedLV2Items);
     this.enableMergeButton = this.AtLeastOneSelectedAssetCanBeMerged();
 }
        public override bool IsRenamingItemAllowed(TreeViewItem item)
        {
            IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);

            return((!hierarchyProperty.Find(item.id, null) || hierarchyProperty.isMainRepresentation) && item.parent != null);
        }
 private void DoSelectionChange()
 {
   HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
   List<string> stringList = new List<string>(Selection.objects.Length);
   foreach (UnityEngine.Object @object in Selection.objects)
   {
     if (hierarchyProperty.Find(@object.GetInstanceID(), (int[]) null))
       stringList.Add(hierarchyProperty.guid);
   }
   for (int index = 0; index < this.downloadConflicts.Length; ++index)
     this.selectedLV1Items[index] = stringList.Contains(this.downloadConflicts[index]);
   for (int index = 0; index < this.nameConflicts.Length; ++index)
     this.selectedLV2Items[index] = stringList.Contains(this.nameConflicts[index]);
   this.lv1HasSelection = this.HasTrue(ref this.selectedLV1Items);
   this.lv2HasSelection = this.HasTrue(ref this.selectedLV2Items);
   this.enableMergeButton = this.AtLeastOneSelectedAssetCanBeMerged();
 }
Exemplo n.º 30
0
		internal static void StartDrag(int draggedInstanceID, List<int> selectedInstanceIDs)
		{
			DragAndDrop.PrepareStartDrag();
			string title = string.Empty;
			if (ProjectWindowUtil.IsFavoritesItem(draggedInstanceID))
			{
				DragAndDrop.SetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData, draggedInstanceID);
				DragAndDrop.objectReferences = new UnityEngine.Object[0];
			}
			else
			{
				bool flag = false;
				HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
				if (hierarchyProperty.Find(draggedInstanceID, null))
				{
					flag = hierarchyProperty.isFolder;
				}
				DragAndDrop.objectReferences = ProjectWindowUtil.GetDragAndDropObjects(draggedInstanceID, selectedInstanceIDs);
				DragAndDrop.SetGenericData(ProjectWindowUtil.k_IsFolderGenericData, (!flag) ? string.Empty : "isFolder");
				string[] dragAndDropPaths = ProjectWindowUtil.GetDragAndDropPaths(draggedInstanceID, selectedInstanceIDs);
				if (dragAndDropPaths.Length > 0)
				{
					DragAndDrop.paths = dragAndDropPaths;
				}
				if (DragAndDrop.objectReferences.Length > 1)
				{
					title = "<Multiple>";
				}
				else
				{
					title = ObjectNames.GetDragAndDropTitle(InternalEditorUtility.GetObjectFromInstanceID(draggedInstanceID));
				}
			}
			DragAndDrop.StartDrag(title);
		}
Exemplo n.º 31
0
		private void SetExpandedRecurse(int instanceID, bool expand)
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			if (hierarchyProperty.Find(instanceID, this.m_ExpandedArray))
			{
				this.SetExpanded(instanceID, expand);
				int depth = hierarchyProperty.depth;
				while (hierarchyProperty.Next(null) && hierarchyProperty.depth > depth)
				{
					this.SetExpanded(hierarchyProperty.instanceID, expand);
				}
			}
		}
Exemplo n.º 32
0
 private void DoSelectionChange()
 {
   if (this.committing)
   {
     this.selectionChangedWhileCommitting = true;
   }
   else
   {
     HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
     List<string> guids = new List<string>(Selection.objects.Length);
     foreach (UnityEngine.Object @object in Selection.objects)
     {
       if (hierarchyProperty.Find(@object.GetInstanceID(), (int[]) null))
         guids.Add(hierarchyProperty.guid);
     }
     this.pvHasSelection = ASCommitWindow.MarkSelected(this.pv, guids);
   }
 }
Exemplo n.º 33
0
		private bool FrameObject(UnityEngine.Object target)
		{
			if (target == null)
			{
				return false;
			}
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			if (hierarchyProperty.Find(target.GetInstanceID(), null))
			{
				while (hierarchyProperty.Parent())
				{
					this.SetExpanded(hierarchyProperty.instanceID, true);
				}
			}
			hierarchyProperty.Reset();
			if (hierarchyProperty.Find(target.GetInstanceID(), this.m_ExpandedArray))
			{
				this.ScrollTo(ASHistoryFileView.m_RowHeight * (float)hierarchyProperty.row + this.m_SpaceAtTheTop);
				return true;
			}
			return false;
		}
Exemplo n.º 34
0
 private void DoSelectionChange()
 {
     HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
     List<string> guids = new List<string>(Selection.objects.Length);
     foreach (Object obj2 in Selection.objects)
     {
         if (property.Find(obj2.GetInstanceID(), null))
         {
             guids.Add(property.guid);
         }
     }
     if (this.pv1hasSelection)
     {
         this.pv1hasSelection = MarkSelected(this.pv1state, guids);
     }
     if (!this.pv1hasSelection)
     {
         if (this.pv2hasSelection)
         {
             this.pv2hasSelection = MarkSelected(this.pv2state, guids);
         }
         if (!this.pv2hasSelection)
         {
             this.pv1hasSelection = MarkSelected(this.pv1state, guids);
             if (!this.pv1hasSelection)
             {
                 this.pv2hasSelection = MarkSelected(this.pv2state, guids);
             }
         }
     }
 }
        public override void FetchData()
        {
            int depth = 0;

            base.m_RootItem = new TreeViewItem(this.m_RootInstanceID, depth, null, CreateDisplayName(this.m_RootInstanceID));
            if (!base.showRootNode)
            {
                this.SetExpanded(base.m_RootItem, true);
            }
            IHierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);

            property.Reset();
            if (!property.Find(this.m_RootInstanceID, null))
            {
                Debug.LogError("Root Asset with id " + this.m_RootInstanceID + " not found!!");
            }
            int minDepth = property.depth + (!base.showRootNode ? 1 : 0);

            int[]     expanded = base.expandedIDs.ToArray();
            Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);

            base.m_VisibleRows = new List <TreeViewItem>();
            while (property.NextWithDepthCheck(expanded, minDepth))
            {
                if (!this.foldersOnly || property.isFolder)
                {
                    TreeViewItem item;
                    depth = property.depth - minDepth;
                    if (property.isFolder)
                    {
                        item = new FolderTreeItem(property.instanceID, depth, null, property.name);
                    }
                    else
                    {
                        item = new NonFolderTreeItem(property.instanceID, depth, null, property.name);
                    }
                    if (property.isFolder && !property.hasChildren)
                    {
                        item.icon = textured;
                    }
                    else
                    {
                        item.icon = property.icon;
                    }
                    if (property.hasChildren)
                    {
                        item.AddChild(null);
                    }
                    base.m_VisibleRows.Add(item);
                }
            }
            TreeViewUtility.SetChildParentReferences(base.m_VisibleRows, base.m_RootItem);
            if (this.foldersFirst)
            {
                FoldersFirstRecursive(base.m_RootItem);
                base.m_VisibleRows.Clear();
                base.GetVisibleItemsRecursive(base.m_RootItem, base.m_VisibleRows);
            }
            base.m_NeedRefreshVisibleFolders = false;
            bool revealSelectionAndFrameLastSelected = false;

            base.m_TreeView.SetSelection(Selection.instanceIDs, revealSelectionAndFrameLastSelected);
        }
Exemplo n.º 36
0
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            HierarchyProperty property = new HierarchyProperty(HierarchyType.GameObjects);

            if ((parentItem == null) || (targetItem == null))
            {
                return(InternalEditorUtility.HierarchyWindowDrag(null, perform, InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon));
            }
            if (this.allowDragBetween)
            {
                if (((dropPos == TreeViewDragging.DropPosition.Above) || (targetItem == null)) || !property.Find(targetItem.id, null))
                {
                    property = null;
                }
            }
            else if (((dropPos == TreeViewDragging.DropPosition.Above) || (parentItem == null)) || !property.Find(parentItem.id, null))
            {
                property = null;
            }
            InternalEditorUtility.HierarchyDropMode kHierarchyDragNormal = InternalEditorUtility.HierarchyDropMode.kHierarchyDragNormal;
            if (this.allowDragBetween)
            {
                kHierarchyDragNormal = (dropPos != TreeViewDragging.DropPosition.Upon) ? InternalEditorUtility.HierarchyDropMode.kHierarchyDropBetween : InternalEditorUtility.HierarchyDropMode.kHierarchyDropUpon;
            }
            if (((parentItem != null) && (parentItem == targetItem)) && (dropPos != TreeViewDragging.DropPosition.Above))
            {
                kHierarchyDragNormal |= InternalEditorUtility.HierarchyDropMode.kHierarchyDropAfterParent;
            }
            return(InternalEditorUtility.HierarchyWindowDrag(property, perform, kHierarchyDragNormal));
        }
Exemplo n.º 37
0
        public override void FetchData()
        {
            int depth = 0;

            this.m_RootItem = new TreeViewItem(this.m_RootInstanceID, depth, null, AssetsTreeViewDataSource.CreateDisplayName(this.m_RootInstanceID));
            if (!base.showRootNode)
            {
                this.SetExpanded(this.m_RootItem, true);
            }
            IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);

            hierarchyProperty.Reset();
            if (!hierarchyProperty.Find(this.m_RootInstanceID, null))
            {
                Debug.LogError("Root Asset with id " + this.m_RootInstanceID + " not found!!");
            }
            int num = hierarchyProperty.depth + ((!base.showRootNode) ? 1 : 0);

            int[]     expanded = base.expandedIDs.ToArray();
            Texture2D icon     = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);

            this.m_VisibleRows = new List <TreeViewItem>();
            while (hierarchyProperty.NextWithDepthCheck(expanded, num))
            {
                if (!this.foldersOnly || hierarchyProperty.isFolder)
                {
                    depth = hierarchyProperty.depth - num;
                    TreeViewItem treeViewItem;
                    if (hierarchyProperty.isFolder)
                    {
                        treeViewItem = new AssetsTreeViewDataSource.FolderTreeItem(hierarchyProperty.instanceID, depth, null, hierarchyProperty.name);
                    }
                    else
                    {
                        treeViewItem = new AssetsTreeViewDataSource.NonFolderTreeItem(hierarchyProperty.instanceID, depth, null, hierarchyProperty.name);
                    }
                    if (hierarchyProperty.isFolder && !hierarchyProperty.hasChildren)
                    {
                        treeViewItem.icon = icon;
                    }
                    else
                    {
                        treeViewItem.icon = hierarchyProperty.icon;
                    }
                    if (hierarchyProperty.hasChildren)
                    {
                        treeViewItem.AddChild(null);
                    }
                    this.m_VisibleRows.Add(treeViewItem);
                }
            }
            TreeViewUtility.SetChildParentReferences(this.m_VisibleRows, this.m_RootItem);
            if (this.foldersFirst)
            {
                AssetsTreeViewDataSource.FoldersFirstRecursive(this.m_RootItem);
                this.m_VisibleRows.Clear();
                base.GetVisibleItemsRecursive(this.m_RootItem, this.m_VisibleRows);
            }
            this.m_NeedRefreshVisibleFolders = false;
            bool revealSelectionAndFrameLastSelected = false;

            this.m_TreeView.SetSelection(Selection.instanceIDs, revealSelectionAndFrameLastSelected);
        }
Exemplo n.º 38
0
		public bool BeginRename(float delay)
		{
			if (!this.allowRenaming)
			{
				return false;
			}
			if (this.m_State.m_SelectedInstanceIDs.Count != 1)
			{
				return false;
			}
			int num = this.m_State.m_SelectedInstanceIDs[0];
			IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			return (!hierarchyProperty.Find(num, null) || hierarchyProperty.isMainRepresentation) && !this.m_LocalAssets.IsBuiltinAsset(num) && hierarchyProperty.isValid && this.GetRenameOverlay().BeginRename(hierarchyProperty.name, num, delay);
		}
Exemplo n.º 39
0
        public override void FetchData()
        {
            beforeReloading?.Invoke();

            Profiler.BeginSample("SceneHierarchyWindow.FetchData");
            m_RowsPartiallyInitialized = false;
            double fetchStartTime = EditorApplication.timeSinceStartup;

            HierarchyProperty property = CreateHierarchyProperty();

            if (m_RootInstanceID != 0)
            {
                bool found = property.Find(m_RootInstanceID, null);
                if (!found)
                {
                    Debug.LogError("Root gameobject with id " + m_RootInstanceID + " not found!!");
                    m_RootInstanceID = 0;
                    property.Reset();
                }
            }

            CreateRootItem(property);

            // Must be set before SetSelection (they calls GetRows which will fetch again if m_NeedRefreshVisibleFolders = true)
            m_NeedRefreshRows = false;

            m_NeedsChildParentReferenceSetup = true;

            bool subTreeWanted = m_RootInstanceID != 0;
            bool isSearching   = !string.IsNullOrEmpty(m_SearchString);

            if (isSearching || subTreeWanted)
            {
                if (isSearching)
                {
                    property.SetSearchFilter(m_SearchString, (int)m_SearchMode);
                }

                InitializeProgressivly(property, subTreeWanted, isSearching);
            }
            else
            {
                // We delay the setup of the full data and calling SetChildParentReferences to ensure fast reloading of
                // the game object hierarchy
                InitializeMinimal();
            }

            double fetchEndTime   = EditorApplication.timeSinceStartup;
            double fetchTotalTime = fetchEndTime - fetchStartTime;
            double fetchDeltaTime = fetchEndTime - m_LastFetchTime;

            // If we have two relatively close consecutive fetches check execution time.
            if (fetchDeltaTime > k_FetchDelta && fetchTotalTime > k_LongFetchTime)
            {
                m_DelayedFetches++;
            }
            else
            {
                m_DelayedFetches = 0;
            }
            m_LastFetchTime = fetchStartTime;

            // We want to reset selection on copy/duplication/delete
            m_TreeView.SetSelection(Selection.instanceIDs, false); // use false because we might just be expanding/collapsing a Item (which would prevent collapsing a Item with a selected child)

            CreateSceneHeaderItems();

            if (SceneHierarchy.s_Debug)
            {
                Debug.Log("Fetch time: " + fetchTotalTime * 1000.0 + " ms, alphaSort = " + IsUsingAlphaSort());
            }

            Profiler.EndSample();
        }
        public override void FetchData()
        {
            Profiler.BeginSample("SceneHierarchyWindow.FetchData");
            int               depth             = 0;
            double            timeSinceStartup  = EditorApplication.timeSinceStartup;
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects);

            hierarchyProperty.Reset();
            hierarchyProperty.alphaSorted = this.IsUsingAlphaSort();
            if (this.m_RootInstanceID != 0)
            {
                bool   flag        = hierarchyProperty.Find(this.m_RootInstanceID, null);
                string displayName = (!flag) ? "RootOfSceneHierarchy" : hierarchyProperty.name;
                this.m_RootItem = new GameObjectTreeViewItem(this.m_RootInstanceID, depth, null, displayName);
                if (!flag)
                {
                    Debug.LogError("Root gameobject with id " + this.m_RootInstanceID + " not found!!");
                }
            }
            else
            {
                this.m_RootItem = new GameObjectTreeViewItem(this.m_RootInstanceID, depth, null, "RootOfSceneHierarchy");
            }
            if (!base.showRootNode)
            {
                this.SetExpanded(this.m_RootItem, true);
            }
            bool flag2 = !string.IsNullOrEmpty(this.m_SearchString);

            if (flag2)
            {
                hierarchyProperty.SetSearchFilter(this.m_SearchString, this.m_SearchMode);
            }
            this.m_VisibleRows = this.CalcVisibleItems(hierarchyProperty, flag2);
            this.m_NeedsChildParentReferenceSetup = true;
            this.m_NeedRefreshVisibleFolders      = false;
            if (this.sortingState.sortingObject != null && this.sortingState.implementsCompare)
            {
                this.SortVisibleRows();
            }
            double timeSinceStartup2 = EditorApplication.timeSinceStartup;
            double num  = timeSinceStartup2 - timeSinceStartup;
            double num2 = timeSinceStartup2 - this.m_LastFetchTime;

            if (num2 > 0.1 && num > 0.05)
            {
                this.m_DelayedFetches++;
            }
            else
            {
                this.m_DelayedFetches = 0;
            }
            this.m_LastFetchTime = timeSinceStartup;
            this.m_TreeView.SetSelection(Selection.instanceIDs, false);
            if (SceneHierarchyWindow.s_Debug)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Fetch time: ",
                    num * 1000.0,
                    " ms, alphaSort = ",
                    this.IsUsingAlphaSort()
                }));
            }
            Profiler.EndSample();
        }
        public override void FetchData()
        {
            Profiler.BeginSample("SceneHierarchyWindow.FetchData");
            this.m_RowsPartiallyInitialized = false;
            double            timeSinceStartup  = EditorApplication.timeSinceStartup;
            HierarchyProperty hierarchyProperty = this.CreateHierarchyProperty();

            if (this.m_RootInstanceID != 0)
            {
                if (!hierarchyProperty.Find(this.m_RootInstanceID, null))
                {
                    Debug.LogError("Root gameobject with id " + this.m_RootInstanceID + " not found!!");
                    this.m_RootInstanceID = 0;
                    hierarchyProperty.Reset();
                }
            }
            this.CreateRootItem(hierarchyProperty);
            this.m_NeedRefreshRows = false;
            this.m_NeedsChildParentReferenceSetup = true;
            bool flag  = this.m_RootInstanceID != 0;
            bool flag2 = !string.IsNullOrEmpty(this.m_SearchString);

            if (flag2 || flag)
            {
                if (flag2)
                {
                    hierarchyProperty.SetSearchFilter(this.m_SearchString, this.m_SearchMode);
                }
                this.InitializeProgressivly(hierarchyProperty, flag, flag2);
            }
            else
            {
                this.InitializeMinimal();
            }
            double timeSinceStartup2 = EditorApplication.timeSinceStartup;
            double num  = timeSinceStartup2 - timeSinceStartup;
            double num2 = timeSinceStartup2 - this.m_LastFetchTime;

            if (num2 > 0.1 && num > 0.05)
            {
                this.m_DelayedFetches++;
            }
            else
            {
                this.m_DelayedFetches = 0;
            }
            this.m_LastFetchTime = timeSinceStartup;
            this.m_TreeView.SetSelection(Selection.instanceIDs, false);
            this.CreateSceneHeaderItems();
            if (SceneHierarchyWindow.s_Debug)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Fetch time: ",
                    num * 1000.0,
                    " ms, alphaSort = ",
                    this.IsUsingAlphaSort()
                }));
            }
            Profiler.EndSample();
        }
        void FolderBrowsing()
        {
            // We are not concerned with assets being added multiple times as we only show the contents
            // of each selected folder. This is an issue when searching recursively into child folders.
            List <FilterResult> list = new List <FilterResult>();
            HierarchyProperty   property;

            foreach (string folderPath in m_SearchFilter.folders)
            {
                if (folderPath == PackageManager.Folders.GetPackagesPath())
                {
                    var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(m_SearchFilter.skipHidden);
                    foreach (var package in packages)
                    {
                        var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath);
                        property = new HierarchyProperty(package.assetPath);
                        if (property.Find(packageFolderInstanceId, null))
                        {
                            FilterResult result = new FilterResult();
                            CopyPropertyData(ref result, property);
                            result.name = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name;
                            list.Add(result);
                        }
                    }
                    continue;
                }

                if (m_SearchFilter.skipHidden && !PackageManagerUtilityInternal.IsPathInVisiblePackage(folderPath))
                {
                    continue;
                }

                int folderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(folderPath);
                property = new HierarchyProperty(folderPath);
                property.SetSearchFilter(m_SearchFilter);

                int   folderDepth = property.depth;
                int[] expanded    = { folderInstanceID };
                Dictionary <string, List <FilterResult> > subAssets = new Dictionary <string, List <FilterResult> >();
                List <FilterResult> parentAssets = new List <FilterResult>();
                while (property.Next(expanded))
                {
                    if (property.depth <= folderDepth)
                    {
                        break; // current property is outside folder
                    }
                    FilterResult result = new FilterResult();
                    CopyPropertyData(ref result, property);
                    //list.Add(result);

                    // Fetch sub assets by expanding the main asset (ignore folders)
                    if (property.hasChildren && !property.isFolder)
                    {
                        parentAssets.Add(result);
                        List <FilterResult> subAssetList = new List <FilterResult>();
                        subAssets.Add(result.guid, subAssetList);
                        System.Array.Resize(ref expanded, expanded.Length + 1);
                        expanded[expanded.Length - 1] = property.instanceID;
                    }
                    else
                    {
                        List <FilterResult> subAssetList;
                        if (subAssets.TryGetValue(result.guid, out subAssetList))
                        {
                            subAssetList.Add(result);
                            subAssets[result.guid] = subAssetList;
                        }
                        else
                        {
                            parentAssets.Add(result);
                        }
                    }
                }
                parentAssets.Sort((result1, result2) => EditorUtility.NaturalCompare(result1.name, result2.name));
                foreach (FilterResult result in parentAssets)
                {
                    list.Add(result);
                    List <FilterResult> subAssetList;
                    if (subAssets.TryGetValue(result.guid, out subAssetList))
                    {
                        subAssetList.Sort((result1, result2) => EditorUtility.NaturalCompare(result1.name, result2.name));
                        foreach (FilterResult subasset in subAssetList)
                        {
                            list.Add(subasset);
                        }
                    }
                }
            }
            m_Results = list.ToArray();
        }
        public override void FetchData()
        {
            // Create root Item
            int depth     = 0;
            var multiRoot = (m_Roots.Count > 1);

            if (multiRoot)
            {
                m_RootItem = new TreeViewItem(-1, depth, null, "Invisible Root Item");
                SetExpanded(m_RootItem, true);
            }
            else
            {
                var rootInstanceID = m_Roots[0].instanceID;
                var displayName    = m_Roots[0].displayName ?? CreateDisplayName(rootInstanceID);
                m_RootItem = new TreeViewItem(rootInstanceID, depth, null, displayName);
                SetExpanded(m_RootItem, true);
            }

            m_Rows = new List <TreeViewItem>(m_Roots.Count * 256);
            Texture2D emptyFolderIcon   = EditorGUIUtility.FindTexture(EditorResources.emptyFolderIconName);
            Texture2D folderIcon        = EditorGUIUtility.FindTexture(EditorResources.folderIconName);
            var       assetsInstanceIDs = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets");
            var       projectPath       = Path.GetFileName(Directory.GetCurrentDirectory());

            // Fetch root Items
            m_RootsTreeViewItem = new Dictionary <string, TreeViewItem>(m_Roots.Count);
            foreach (var root in m_Roots)
            {
                var rootInstanceID = root.instanceID;
                var displayName    = root.displayName ?? CreateDisplayName(rootInstanceID);
                var rootPath       = root.path ?? AssetDatabase.GetAssetPath(rootInstanceID);

                var property = new HierarchyProperty(rootPath);
                if (!root.skipValidation && !property.Find(rootInstanceID, null))
                {
                    Debug.LogError("Root Asset with id " + rootInstanceID + " not valid!!");
                    continue;
                }

                var          minDepth = property.depth;
                var          subDepth = multiRoot ? 0 : -1;
                TreeViewItem rootItem;
                if (multiRoot)
                {
                    var parentItem = m_RootItem;
                    var rootDepth  = minDepth;
                    rootDepth++;

                    // Find parent treeView item
                    var parentPath = Directory.GetParent(rootPath).Name;
                    if (parentPath != projectPath)
                    {
                        if (!m_RootsTreeViewItem.TryGetValue(parentPath, out parentItem))
                        {
                            Debug.LogError("Cannot find parent for " + rootInstanceID);
                            continue;
                        }

                        rootDepth++;
                        subDepth++;
                    }

                    // Create root item TreeView item
                    if (subDepth > 0)
                    {
                        rootItem = new FolderTreeItem(rootInstanceID, rootDepth, parentItem, displayName);
                    }
                    else
                    {
                        rootItem = new RootTreeItem(rootInstanceID, rootDepth, parentItem, displayName);
                    }
                    rootItem.icon = folderIcon;
                    parentItem.AddChild(rootItem);
                }
                else
                {
                    rootItem = m_RootItem;
                }

                m_RootsTreeViewItem[rootPath] = rootItem;

                var  expandIDs      = GetExpandedIDs();
                var  rows           = new List <TreeViewItem>();
                bool shouldExpandIt = m_ExpandAtFirstTime && (rootItem.id == assetsInstanceIDs);
                if (IsExpanded(rootItem.id) && (rootItem == m_RootItem || IsExpanded(rootItem.parent.id)) || shouldExpandIt)
                {
                    m_ExpandAtFirstTime = false;

                    while (property.NextWithDepthCheck(expandIDs, minDepth))
                    {
                        if (!foldersOnly || property.isFolder)
                        {
                            depth = property.depth - minDepth;
                            TreeViewItem item;
                            if (property.isFolder)
                            {
                                item = new FolderTreeItem(property.instanceID, depth + subDepth, null, property.name);
                            }
                            else
                            {
                                item = new NonFolderTreeItem(property.instanceID, depth + subDepth, null, property.name);
                            }

                            if (property.isFolder && !property.hasChildren)
                            {
                                item.icon = emptyFolderIcon;
                            }
                            else
                            {
                                item.icon = property.icon;
                            }

                            if (property.hasChildren)
                            {
                                item.AddChild(null); // add a dummy child in children list to ensure we show the collapse arrow (because we do not fetch data for collapsed items)
                            }
                            rows.Add(item);
                        }
                    }

                    // Setup reference between child and parent items
                    TreeViewUtility.SetChildParentReferences(rows, rootItem);
                }
                else
                {
                    rootItem.AddChild(null);
                }

                if (shouldExpandIt && !IsExpanded(rootItem))
                {
                    SetExpanded(rootItem, true);
                }

                if (multiRoot && IsExpanded(rootItem.parent.id))
                {
                    m_Rows.Add(rootItem);
                }

                ((List <TreeViewItem>)m_Rows).AddRange(rows);
            }

            if (foldersFirst)
            {
                FoldersFirstRecursive(m_RootItem);
                m_Rows.Clear();
                GetVisibleItemsRecursive(m_RootItem, m_Rows);
            }

            // Must be called before InitSelection (it calls GetVisibleItems)
            m_NeedRefreshRows = false;

            // We want to reset selection on copy/duplication/delete
            bool frameLastSelected = false; // use false because we might just be expanding/collapsing a Item (which would prevent collapsing a Item with a selected child)

            m_TreeView.SetSelection(Selection.instanceIDs, frameLastSelected);
        }
Exemplo n.º 44
0
 private void DoSelectionChange()
 {
     if (this.committing)
     {
         this.selectionChangedWhileCommitting = true;
     }
     else
     {
         HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
         List<string> guids = new List<string>(Selection.objects.Length);
         foreach (Object obj2 in Selection.objects)
         {
             if (property.Find(obj2.GetInstanceID(), null))
             {
                 guids.Add(property.guid);
             }
         }
         this.pvHasSelection = ASCommitWindow.MarkSelected(this.pv, guids);
     }
 }