Inheritance: IHierarchyProperty
 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);
 }
Esempio n. 2
0
 private void CopyPropertyData(ref FilterResult result, HierarchyProperty property)
 {
     if (result == null)
     {
         result = new 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 = null;
     }
 }
Esempio n. 3
0
        private void AddResults(HierarchyProperty property)
        {
            switch (this.m_SearchFilter.GetState())
            {
                case SearchFilter.State.EmptySearchFilter:
                case SearchFilter.State.SearchingInAssetStore:
                    break;

                case SearchFilter.State.FolderBrowsing:
                    this.FolderBrowsing(property);
                    break;

                case SearchFilter.State.SearchingInAllAssets:
                    this.SearchAllAssets(property);
                    break;

                case SearchFilter.State.SearchingInFolders:
                    this.SearchInFolders(property);
                    break;

                default:
                    Debug.LogError("Unhandled enum!");
                    break;
            }
        }
		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);
 }
	static IEnumerable<GameObject> SceneRoots()
	{
		var prop = new HierarchyProperty(HierarchyType.GameObjects);
		var expanded = new int[0];
		while (prop.Next(expanded)) {
			yield return prop.pptrValue as GameObject;
		}
	}
 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;
 }
Esempio n. 9
0
 private static void ExportScene()
 {
     var prop = new HierarchyProperty(HierarchyType.GameObjects);
     var expanded = new int[0];
     while (prop.Next(expanded))
     {
         var gameObject = prop.pptrValue as GameObject;
         examineGameObject(gameObject);
     }
 }
 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 static List<UnityEngine.Object> FindAssetsOfType(string[] classNames)
 {
   HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
   hierarchyProperty.SetSearchFilter(new SearchFilter()
   {
     classNames = classNames
   });
   List<UnityEngine.Object> objectList = new List<UnityEngine.Object>();
   while (hierarchyProperty.Next((int[]) null))
     objectList.Add(hierarchyProperty.pptrValue);
   return objectList;
 }
 private List<TreeViewItem> CalcVisibleItems(HierarchyProperty property, bool hasSearchString)
 {
     int depth = property.depth;
     int[] expanded = base.expandedIDs.ToArray();
     List<TreeViewItem> list = new List<TreeViewItem>();
     while (property.NextWithDepthCheck(expanded, depth))
     {
         int num = this.GetAdjustedItemDepth(hasSearchString, depth, property.depth);
         GameObjectTreeViewItem item = this.CreateTreeViewItem(property, hasSearchString, num, true);
         list.Add(item);
     }
     return list;
 }
 private GameObjectTreeViewItem CreateTreeViewItem(HierarchyProperty property, bool hasSearchString, int depth, bool shouldDisplay)
 {
     GameObjectTreeViewItem item = new GameObjectTreeViewItem(property.instanceID, depth, null, string.Empty) {
         colorCode = property.colorCode,
         objectPPTR = property.pptrValue,
         shouldDisplay = shouldDisplay
     };
     if (!hasSearchString && property.hasChildren)
     {
         item.children = LazyTreeViewDataSource.CreateChildListForCollapsedParent();
     }
     return item;
 }
Esempio n. 14
0
        /// <summary>
        /// Update the scene blackboard's instance ids.
        /// </summary>
        static void UpdateSceneInstanceIDs () {
            // The HierarchyProperty is an undocumented class very uesfull to get all GameObjects in the scene or assets in the project
            var hierarchyProperty = new HierarchyProperty (HierarchyType.GameObjects);
            // Search for Blackboards
            hierarchyProperty.SetSearchFilter("internalblackboard", (int)SearchableEditorWindow.SearchModeHierarchyWindow.Type);
            // Reset the list of game Object instance ids
            s_SceneInstanceIDs.Clear();

            // Go through all objects
            while (hierarchyProperty.Next(null)) {
                // Populate the GameObject instanceID list
                s_SceneInstanceIDs.Add(hierarchyProperty.instanceID);
            }
        }
 private static List<UnityEngine.Object> FindAssetsOfType(string[] classNames)
 {
     HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
     SearchFilter filter = new SearchFilter {
         classNames = classNames
     };
     property.SetSearchFilter(filter);
     List<UnityEngine.Object> list = new List<UnityEngine.Object>();
     while (property.Next(null))
     {
         list.Add(property.pptrValue);
     }
     return list;
 }
		private void ReadAssetDatabase(TreeViewItem parent, int baseDepth)
		{
			IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			hierarchyProperty.Reset();
			Texture2D texture2D = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
			Texture2D texture2D2 = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);
			List<TreeViewItem> list = new List<TreeViewItem>();
			while (hierarchyProperty.Next(null))
			{
				if (hierarchyProperty.isFolder)
				{
					list.Add(new TreeViewItem(hierarchyProperty.instanceID, baseDepth + hierarchyProperty.depth, null, hierarchyProperty.name)
					{
						icon = (!hierarchyProperty.hasChildren) ? texture2D2 : texture2D
					});
				}
			}
			TreeViewUtility.SetChildParentReferences(list, parent);
		}
 private void ReadAssetDatabase(TreeViewItem parent, int baseDepth)
 {
     IHierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
     property.Reset();
     Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
     Texture2D textured2 = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);
     List<TreeViewItem> visibleItems = new List<TreeViewItem>();
     while (property.Next(null))
     {
         if (property.isFolder)
         {
             TreeViewItem item = new TreeViewItem(property.instanceID, baseDepth + property.depth, null, property.name) {
                 icon = !property.hasChildren ? textured2 : textured
             };
             visibleItems.Add(item);
         }
     }
     TreeViewUtility.SetChildParentReferences(visibleItems, parent);
 }
Esempio n. 18
0
 bool IsSceneHeader(HierarchyProperty property)
 {
     return(property.pptrValue == null);
 }
		private void ScrollToDeletedItem(int index)
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			float num = this.m_SpaceAtTheTop + (float)hierarchyProperty.CountRemaining(this.m_ExpandedArray) * ASHistoryFileView.m_RowHeight + 6f;
			if (index == -1)
			{
				this.ScrollTo(num);
			}
			else
			{
				this.ScrollTo(num + (float)(index + 1) * ASHistoryFileView.m_RowHeight);
			}
		}
		public void DoGUI(ASHistoryWindow parentWin, Rect theRect, bool focused)
		{
			if (ASHistoryFileView.ms_Styles == null)
			{
				ASHistoryFileView.ms_Styles = new ASHistoryFileView.Styles();
			}
			this.m_ScreenRect = theRect;
			Hashtable hashtable = new Hashtable();
			UnityEngine.Object[] objects = Selection.objects;
			for (int i = 0; i < objects.Length; i++)
			{
				UnityEngine.Object @object = objects[i];
				hashtable.Add(@object.GetInstanceID(), null);
			}
			this.m_FileViewControlID = GUIUtility.GetControlID(ASHistoryFileView.ms_FileViewHash, FocusType.Native);
			this.KeyboardGUI(parentWin);
			focused &= (GUIUtility.keyboardControl == this.m_FileViewControlID);
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			int num = hierarchyProperty.CountRemaining(this.m_ExpandedArray);
			int num2 = (!this.DeletedItemsToggle) ? 0 : this.m_DelPVstate.lv.totalRows;
			Rect viewRect = new Rect(0f, 0f, 1f, (float)(num + 2 + num2) * ASHistoryFileView.m_RowHeight + 16f);
			this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect);
			theRect.width = ((viewRect.height <= this.m_ScreenRect.height) ? theRect.width : (theRect.width - 18f));
			int num3 = Mathf.RoundToInt(this.m_ScrollPosition.y - 6f - ASHistoryFileView.m_RowHeight) / Mathf.RoundToInt(ASHistoryFileView.m_RowHeight);
			if (num3 > num)
			{
				num3 = num;
			}
			else
			{
				if (num3 < 0)
				{
					num3 = 0;
					this.m_ScrollPosition.y = 0f;
				}
			}
			GUIContent gUIContent = new GUIContent();
			Event current = Event.current;
			GUIStyle gUIStyle = new GUIStyle(ASHistoryFileView.ms_Styles.label);
			Texture2D image = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
			float num4 = (float)num3 * ASHistoryFileView.m_RowHeight + 3f;
			float num5 = this.m_ScreenRect.height + this.m_ScrollPosition.y;
			Rect position = new Rect(0f, num4, theRect.width, ASHistoryFileView.m_RowHeight);
			if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
			{
				this.SelType = ASHistoryFileView.SelectionType.All;
				GUIUtility.keyboardControl = this.m_FileViewControlID;
				this.ScrollTo(0f);
				parentWin.DoLocalSelectionChange();
				current.Use();
			}
			gUIContent = new GUIContent("Entire Project");
			gUIContent.image = image;
			int left = (int)this.m_BaseIndent;
			gUIStyle.padding.left = 3;
			if (Event.current.type == EventType.Repaint)
			{
				gUIStyle.Draw(position, gUIContent, false, false, this.SelType == ASHistoryFileView.SelectionType.All, focused);
			}
			num4 += ASHistoryFileView.m_RowHeight + 3f;
			hierarchyProperty.Reset();
			hierarchyProperty.Skip(num3, this.m_ExpandedArray);
			while (hierarchyProperty.Next(this.m_ExpandedArray) && num4 <= num5)
			{
				int instanceID = hierarchyProperty.instanceID;
				position = new Rect(0f, num4, theRect.width, ASHistoryFileView.m_RowHeight);
				if (Event.current.type == EventType.Repaint)
				{
					gUIContent.text = hierarchyProperty.name;
					gUIContent.image = hierarchyProperty.icon;
					left = (int)(this.m_BaseIndent + this.m_Indent * (float)hierarchyProperty.depth);
					gUIStyle.padding.left = left;
					bool on = hashtable.Contains(instanceID);
					gUIStyle.Draw(position, gUIContent, false, false, on, focused);
				}
				if (hierarchyProperty.hasChildren)
				{
					bool flag = hierarchyProperty.IsExpanded(this.m_ExpandedArray);
					GUI.changed = false;
					Rect position2 = new Rect(this.m_BaseIndent + this.m_Indent * (float)hierarchyProperty.depth - this.m_FoldoutSize, num4, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight);
					flag = GUI.Toggle(position2, flag, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
					if (GUI.changed)
					{
						if (Event.current.alt)
						{
							this.SetExpandedRecurse(instanceID, flag);
						}
						else
						{
							this.SetExpanded(instanceID, flag);
						}
					}
				}
				if (current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
				{
					GUIUtility.keyboardControl = this.m_FileViewControlID;
					if (Event.current.clickCount == 2)
					{
						AssetDatabase.OpenAsset(instanceID);
						GUIUtility.ExitGUI();
					}
					else
					{
						if (position.Contains(current.mousePosition))
						{
							this.SelectionClick(hierarchyProperty);
						}
					}
					current.Use();
				}
				num4 += ASHistoryFileView.m_RowHeight;
			}
			num4 += 3f;
			this.DoDeletedItemsGUI(parentWin, theRect, gUIStyle, num4, num5, focused);
			GUI.EndScrollView();
			EventType type = current.type;
			if (type != EventType.MouseDown)
			{
				if (type == EventType.MouseUp)
				{
					if (GUIUtility.hotControl == this.m_FileViewControlID)
					{
						if (this.m_ScreenRect.Contains(current.mousePosition))
						{
							Selection.activeObject = null;
						}
						GUIUtility.hotControl = 0;
						current.Use();
					}
				}
			}
			else
			{
				if (current.button == 0 && this.m_ScreenRect.Contains(current.mousePosition))
				{
					GUIUtility.hotControl = this.m_FileViewControlID;
					current.Use();
				}
			}
			this.HandleFraming();
		}
		private void SelectionClick(HierarchyProperty property)
		{
			if (EditorGUI.actionKey)
			{
				ArrayList arrayList = new ArrayList();
				arrayList.AddRange(Selection.objects);
				if (arrayList.Contains(property.pptrValue))
				{
					arrayList.Remove(property.pptrValue);
				}
				else
				{
					arrayList.Add(property.pptrValue);
				}
				Selection.objects = (arrayList.ToArray(typeof(UnityEngine.Object)) as UnityEngine.Object[]);
			}
			else
			{
				if (Event.current.shift)
				{
					HierarchyProperty firstSelected = this.GetFirstSelected();
					HierarchyProperty lastSelected = this.GetLastSelected();
					if (!firstSelected.isValid)
					{
						Selection.activeObject = property.pptrValue;
						return;
					}
					HierarchyProperty hierarchyProperty;
					HierarchyProperty hierarchyProperty2;
					if (property.row > lastSelected.row)
					{
						hierarchyProperty = firstSelected;
						hierarchyProperty2 = property;
					}
					else
					{
						hierarchyProperty = property;
						hierarchyProperty2 = lastSelected;
					}
					ArrayList arrayList2 = new ArrayList();
					arrayList2.Add(hierarchyProperty.pptrValue);
					while (hierarchyProperty.Next(this.m_ExpandedArray))
					{
						arrayList2.Add(hierarchyProperty.pptrValue);
						if (hierarchyProperty.instanceID == hierarchyProperty2.instanceID)
						{
							break;
						}
					}
					Selection.objects = (arrayList2.ToArray(typeof(UnityEngine.Object)) as UnityEngine.Object[]);
				}
				else
				{
					Selection.activeObject = property.pptrValue;
				}
			}
			this.SelType = ASHistoryFileView.SelectionType.Items;
			this.FrameObject(Selection.activeObject);
		}
		private HierarchyProperty GetFirst()
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			if (hierarchyProperty.Next(this.m_ExpandedArray))
			{
				return hierarchyProperty;
			}
			return null;
		}
Esempio n. 23
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);
   }
 }
		private int ControlIDForProperty(HierarchyProperty property)
		{
			if (property != null)
			{
				return property.row + 10000000;
			}
			return -1;
		}
Esempio n. 25
0
        public void DoGUI(ASHistoryWindow parentWin, Rect theRect, bool focused)
        {
            if (ASHistoryFileView.ms_Styles == null)
            {
                ASHistoryFileView.ms_Styles = new ASHistoryFileView.Styles();
            }
            this.m_ScreenRect = theRect;
            Hashtable hashtable = new Hashtable();

            UnityEngine.Object[] objects = Selection.objects;
            for (int i = 0; i < objects.Length; i++)
            {
                UnityEngine.Object @object = objects[i];
                hashtable.Add(@object.GetInstanceID(), null);
            }
            this.m_FileViewControlID = GUIUtility.GetControlID(ASHistoryFileView.ms_FileViewHash, FocusType.Passive);
            this.KeyboardGUI(parentWin);
            focused &= (GUIUtility.keyboardControl == this.m_FileViewControlID);
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            int  num      = hierarchyProperty.CountRemaining(this.m_ExpandedArray);
            int  num2     = (!this.DeletedItemsToggle) ? 0 : this.m_DelPVstate.lv.totalRows;
            Rect viewRect = new Rect(0f, 0f, 1f, (float)(num + 2 + num2) * ASHistoryFileView.m_RowHeight + 16f);

            this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect);
            theRect.width         = ((viewRect.height <= this.m_ScreenRect.height) ? theRect.width : (theRect.width - 18f));
            int num3 = Mathf.RoundToInt(this.m_ScrollPosition.y - 6f - ASHistoryFileView.m_RowHeight) / Mathf.RoundToInt(ASHistoryFileView.m_RowHeight);

            if (num3 > num)
            {
                num3 = num;
            }
            else if (num3 < 0)
            {
                num3 = 0;
                this.m_ScrollPosition.y = 0f;
            }
            GUIContent gUIContent = new GUIContent();
            Event      current    = Event.current;
            GUIStyle   gUIStyle   = new GUIStyle(ASHistoryFileView.ms_Styles.label);
            Texture2D  image      = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
            float      num4       = (float)num3 * ASHistoryFileView.m_RowHeight + 3f;
            float      num5       = this.m_ScreenRect.height + this.m_ScrollPosition.y;
            Rect       position   = new Rect(0f, num4, theRect.width, ASHistoryFileView.m_RowHeight);

            if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
            {
                this.SelType = ASHistoryFileView.SelectionType.All;
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.ScrollTo(0f);
                parentWin.DoLocalSelectionChange();
                current.Use();
            }
            gUIContent       = new GUIContent("Entire Project");
            gUIContent.image = image;
            int left = (int)this.m_BaseIndent;

            gUIStyle.padding.left = 3;
            if (Event.current.type == EventType.Repaint)
            {
                gUIStyle.Draw(position, gUIContent, false, false, this.SelType == ASHistoryFileView.SelectionType.All, focused);
            }
            num4 += ASHistoryFileView.m_RowHeight + 3f;
            hierarchyProperty.Reset();
            hierarchyProperty.Skip(num3, this.m_ExpandedArray);
            while (hierarchyProperty.Next(this.m_ExpandedArray) && num4 <= num5)
            {
                int instanceID = hierarchyProperty.instanceID;
                position = new Rect(0f, num4, theRect.width, ASHistoryFileView.m_RowHeight);
                if (Event.current.type == EventType.Repaint)
                {
                    gUIContent.text       = hierarchyProperty.name;
                    gUIContent.image      = hierarchyProperty.icon;
                    left                  = (int)(this.m_BaseIndent + this.m_Indent * (float)hierarchyProperty.depth);
                    gUIStyle.padding.left = left;
                    bool on = hashtable.Contains(instanceID);
                    gUIStyle.Draw(position, gUIContent, false, false, on, focused);
                }
                if (hierarchyProperty.hasChildren)
                {
                    bool flag = hierarchyProperty.IsExpanded(this.m_ExpandedArray);
                    GUI.changed = false;
                    Rect position2 = new Rect(this.m_BaseIndent + this.m_Indent * (float)hierarchyProperty.depth - this.m_FoldoutSize, num4, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight);
                    flag = GUI.Toggle(position2, flag, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
                    if (GUI.changed)
                    {
                        if (Event.current.alt)
                        {
                            this.SetExpandedRecurse(instanceID, flag);
                        }
                        else
                        {
                            this.SetExpanded(instanceID, flag);
                        }
                    }
                }
                if (current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
                {
                    GUIUtility.keyboardControl = this.m_FileViewControlID;
                    if (Event.current.clickCount == 2)
                    {
                        AssetDatabase.OpenAsset(instanceID);
                        GUIUtility.ExitGUI();
                    }
                    else if (position.Contains(current.mousePosition))
                    {
                        this.SelectionClick(hierarchyProperty);
                    }
                    current.Use();
                }
                num4 += ASHistoryFileView.m_RowHeight;
            }
            num4 += 3f;
            this.DoDeletedItemsGUI(parentWin, theRect, gUIStyle, num4, num5, focused);
            GUI.EndScrollView();
            EventType type = current.type;

            if (type != EventType.MouseDown)
            {
                if (type == EventType.MouseUp)
                {
                    if (GUIUtility.hotControl == this.m_FileViewControlID)
                    {
                        if (this.m_ScreenRect.Contains(current.mousePosition))
                        {
                            Selection.activeObject = null;
                        }
                        GUIUtility.hotControl = 0;
                        current.Use();
                    }
                }
            }
            else if (current.button == 0 && this.m_ScreenRect.Contains(current.mousePosition))
            {
                GUIUtility.hotControl = this.m_FileViewControlID;
                current.Use();
            }
            this.HandleFraming();
        }
        private static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : UnityEngine.Object, new()
        {
            GenericMenu genericMenu = new GenericMenu();
            int         num         = (!(serializedProperty.objectReferenceValue != null)) ? 0 : serializedProperty.objectReferenceValue.GetInstanceID();
            bool        flag        = false;
            UnityType   unityType   = UnityType.FindTypeByName(typeName);
            int         num2        = (unityType == null) ? 0 : unityType.persistentTypeID;

            BuiltinResource[] array = null;
            if (num2 > 0)
            {
                array = EditorGUIUtility.GetBuiltinResourceList(num2);
                BuiltinResource[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    BuiltinResource resource = array2[i];
                    if (resource.m_Name == defaultFieldName)
                    {
                        GenericMenu arg_124_0 = genericMenu;
                        GUIContent  arg_124_1 = new GUIContent(resource.m_Name);
                        bool        arg_124_2 = resource.m_InstanceID == num;

                        /*
                         * if (AssetPopupBackend.<>f__mg$cache0 == null)
                         * {
                         *      AssetPopupBackend.<>f__mg$cache0 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                         * }
                         * arg_124_0.AddItem(arg_124_1, arg_124_2, AssetPopupBackend.<>f__mg$cache0, new object[]
                         * {
                         *      resource.m_InstanceID,
                         *      serializedProperty
                         * });
                         */
                        array = (from x in array
                                 where x != resource
                                 select x).ToArray <BuiltinResource>();
                        flag = true;
                        break;
                    }
                }
            }
            if (!flag)
            {
                /*
                 * GenericMenu arg_1A6_0 = genericMenu;
                 * GUIContent arg_1A6_1 = new GUIContent(defaultFieldName);
                 * bool arg_1A6_2 = num == 0;
                 * if (AssetPopupBackend.<>f__mg$cache1 == null)
                 * {
                 *      AssetPopupBackend.<>f__mg$cache1 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                 * }
                 * arg_1A6_0.AddItem(arg_1A6_1, arg_1A6_2, AssetPopupBackend.<>f__mg$cache1, new object[]
                 * {
                 *      0,
                 *      serializedProperty
                 * });
                 */
            }
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            SearchFilter      searchFilter      = new SearchFilter
            {
                classNames = new string[]
                {
                    typeName
                }
            };

            hierarchyProperty.SetSearchFilter(searchFilter);
            hierarchyProperty.Reset();
            while (hierarchyProperty.Next(null))
            {
                /*
                 * GenericMenu arg_23D_0 = genericMenu;
                 * GUIContent arg_23D_1 = new GUIContent(hierarchyProperty.name);
                 * bool arg_23D_2 = hierarchyProperty.instanceID == num;
                 * if (AssetPopupBackend.<>f__mg$cache2 == null)
                 * {
                 *      AssetPopupBackend.<>f__mg$cache2 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                 * }
                 * arg_23D_0.AddItem(arg_23D_1, arg_23D_2, AssetPopupBackend.<>f__mg$cache2, new object[]
                 * {
                 *      hierarchyProperty.instanceID,
                 *      serializedProperty
                 * });
                 */
            }
            if (num2 > 0 && array != null)
            {
                BuiltinResource[] array3 = array;
                for (int j = 0; j < array3.Length; j++)
                {
                    /*
                     * BuiltinResource builtinResource = array3[j];
                     * GenericMenu arg_2C7_0 = genericMenu;
                     * GUIContent arg_2C7_1 = new GUIContent(builtinResource.m_Name);
                     * bool arg_2C7_2 = builtinResource.m_InstanceID == num;
                     * if (AssetPopupBackend.<>f__mg$cache3 == null)
                     * {
                     *      AssetPopupBackend.<>f__mg$cache3 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                     * }
                     * arg_2C7_0.AddItem(arg_2C7_1, arg_2C7_2, AssetPopupBackend.<>f__mg$cache3, new object[]
                     * {
                     *      builtinResource.m_InstanceID,
                     *      serializedProperty
                     * });
                     */
                }
            }
            genericMenu.AddSeparator("");
            genericMenu.AddItem(EditorGUIUtility.TrTextContent("Create New...", null, null), false, delegate
            {
                T t = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(t, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = t;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });
            genericMenu.DropDown(buttonRect);
        }
Esempio n. 27
0
        private void AssetViewKeyboard()
        {
            KeyCode keyCode = Event.current.keyCode;

            switch (keyCode)
            {
            case KeyCode.KeypadEnter:
                goto IL_1C6;

            case KeyCode.KeypadEquals:
            case KeyCode.Insert:
IL_44:
                if (keyCode != KeyCode.Return)
                {
                    return;
                }
                goto IL_1C6;

            case KeyCode.UpArrow:
            {
                Event.current.Use();
                HierarchyProperty firstSelected = this.GetFirstSelected();
                if (firstSelected != null)
                {
                    if (firstSelected.instanceID == this.GetFirst().instanceID)
                    {
                        this.SelType      = ASHistoryFileView.SelectionType.All;
                        Selection.objects = new UnityEngine.Object[0];
                        this.ScrollTo(0f);
                    }
                    else if (firstSelected.Previous(this.m_ExpandedArray))
                    {
                        UnityEngine.Object pptrValue = firstSelected.pptrValue;
                        this.SelectionClick(firstSelected);
                        this.FrameObject(pptrValue);
                    }
                }
                goto IL_430;
            }

            case KeyCode.DownArrow:
            {
                Event.current.Use();
                HierarchyProperty lastSelected = this.GetLastSelected();
                if (Application.platform == RuntimePlatform.OSXEditor && Event.current.command)
                {
                    this.OpenAssetSelection();
                    GUIUtility.ExitGUI();
                }
                else if (lastSelected != null)
                {
                    if (lastSelected.instanceID == this.GetLast().instanceID)
                    {
                        this.SelType      = ASHistoryFileView.SelectionType.DeletedItemsRoot;
                        Selection.objects = new UnityEngine.Object[0];
                        this.ScrollToDeletedItem(-1);
                    }
                    else if (lastSelected.Next(this.m_ExpandedArray))
                    {
                        UnityEngine.Object pptrValue2 = lastSelected.pptrValue;
                        this.SelectionClick(lastSelected);
                        this.FrameObject(pptrValue2);
                    }
                }
                goto IL_430;
            }

            case KeyCode.RightArrow:
            {
                HierarchyProperty activeSelected = this.GetActiveSelected();
                if (activeSelected != null)
                {
                    this.SetExpanded(activeSelected.instanceID, true);
                }
                goto IL_430;
            }

            case KeyCode.LeftArrow:
            {
                HierarchyProperty activeSelected2 = this.GetActiveSelected();
                if (activeSelected2 != null)
                {
                    this.SetExpanded(activeSelected2.instanceID, false);
                }
                goto IL_430;
            }

            case KeyCode.Home:
                if (this.GetFirst() != null)
                {
                    Selection.activeObject = this.GetFirst().pptrValue;
                    this.FrameObject(Selection.activeObject);
                }
                goto IL_430;

            case KeyCode.End:
                if (this.GetLast() != null)
                {
                    Selection.activeObject = this.GetLast().pptrValue;
                    this.FrameObject(Selection.activeObject);
                }
                goto IL_430;

            case KeyCode.PageUp:
                Event.current.Use();
                if (ASHistoryFileView.OSX)
                {
                    this.m_ScrollPosition.y = this.m_ScrollPosition.y - this.m_ScreenRect.height;
                    if (this.m_ScrollPosition.y < 0f)
                    {
                        this.m_ScrollPosition.y = 0f;
                    }
                }
                else
                {
                    HierarchyProperty hierarchyProperty = this.GetFirstSelected();
                    if (hierarchyProperty != null)
                    {
                        int num = 0;
                        while ((float)num < this.m_ScreenRect.height / ASHistoryFileView.m_RowHeight)
                        {
                            if (!hierarchyProperty.Previous(this.m_ExpandedArray))
                            {
                                hierarchyProperty = this.GetFirst();
                                break;
                            }
                            num++;
                        }
                        UnityEngine.Object pptrValue3 = hierarchyProperty.pptrValue;
                        this.SelectionClick(hierarchyProperty);
                        this.FrameObject(pptrValue3);
                    }
                    else if (this.GetFirst() != null)
                    {
                        Selection.activeObject = this.GetFirst().pptrValue;
                        this.FrameObject(Selection.activeObject);
                    }
                }
                goto IL_430;

            case KeyCode.PageDown:
                Event.current.Use();
                if (ASHistoryFileView.OSX)
                {
                    this.m_ScrollPosition.y = this.m_ScrollPosition.y + this.m_ScreenRect.height;
                }
                else
                {
                    HierarchyProperty hierarchyProperty2 = this.GetLastSelected();
                    if (hierarchyProperty2 != null)
                    {
                        int num2 = 0;
                        while ((float)num2 < this.m_ScreenRect.height / ASHistoryFileView.m_RowHeight)
                        {
                            if (!hierarchyProperty2.Next(this.m_ExpandedArray))
                            {
                                hierarchyProperty2 = this.GetLast();
                                break;
                            }
                            num2++;
                        }
                        UnityEngine.Object pptrValue4 = hierarchyProperty2.pptrValue;
                        this.SelectionClick(hierarchyProperty2);
                        this.FrameObject(pptrValue4);
                    }
                    else if (this.GetLast() != null)
                    {
                        Selection.activeObject = this.GetLast().pptrValue;
                        this.FrameObject(Selection.activeObject);
                    }
                }
                goto IL_430;
            }
            goto IL_44;
IL_1C6:
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                this.OpenAssetSelection();
                GUIUtility.ExitGUI();
            }
IL_430:
            Event.current.Use();
        }
Esempio n. 28
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(EditorResourcesUtility.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);
        }
Esempio n. 29
0
        // private

        static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : Object, new()
        {
            GenericMenu gm = new GenericMenu();

            int selectedInstanceID = serializedProperty.objectReferenceValue != null?serializedProperty.objectReferenceValue.GetInstanceID() : 0;


            bool foundDefaultAsset = false;
            var  type    = UnityEditor.UnityType.FindTypeByName(typeName);
            int  classID = type != null ? type.persistentTypeID : 0;

            BuiltinResource[] resourceList = null;

            // Check the assets for one that matches the default name.
            if (classID > 0)
            {
                resourceList = EditorGUIUtility.GetBuiltinResourceList(classID);
                foreach (var resource in resourceList)
                {
                    if (resource.m_Name == defaultFieldName)
                    {
                        gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                        resourceList      = resourceList.Where(x => x != resource).ToArray();
                        foundDefaultAsset = true;
                        break;
                    }
                }
            }

            // If no defalut asset was found, add defualt null value.
            if (!foundDefaultAsset)
            {
                gm.AddItem(new GUIContent(defaultFieldName), selectedInstanceID == 0, AssetPopupMenuCallback, new object[] { 0, serializedProperty });
            }

            // Add items from asset database
            var property     = new HierarchyProperty(HierarchyType.Assets);
            var searchFilter = new SearchFilter()
            {
                classNames = new[] { typeName }
            };

            property.SetSearchFilter(searchFilter);
            property.Reset();
            while (property.Next(null))
            {
                gm.AddItem(new GUIContent(property.name), property.instanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { property.instanceID, serializedProperty });
            }

            // Add builtin items, except for the already added default item.
            if (classID > 0 && resourceList != null)
            {
                foreach (var resource in resourceList)
                {
                    gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                }
            }

            // Create item
            gm.AddSeparator("");
            gm.AddItem(EditorGUIUtility.TrTextContent("Create New..."), false, delegate
            {
                var newAsset = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(newAsset, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = newAsset;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });

            gm.DropDown(buttonRect);
        }
Esempio n. 30
0
        private static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension) where T : Object, new()
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AssetPopupBackend.\u003CShowAssetsPopupMenu\u003Ec__AnonStorey76 <T> menuCAnonStorey76 = new AssetPopupBackend.\u003CShowAssetsPopupMenu\u003Ec__AnonStorey76 <T>();
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.typeName = typeName;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.fileExtension = fileExtension;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.serializedProperty = serializedProperty;
            GenericMenu genericMenu = new GenericMenu();
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            int num = !(menuCAnonStorey76.serializedProperty.objectReferenceValue != (Object)null) ? 0 : menuCAnonStorey76.serializedProperty.objectReferenceValue.GetInstanceID();

            // ISSUE: reference to a compiler-generated field
            genericMenu.AddItem(new GUIContent("Default"), (num == 0 ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
            {
                (object)0,
                (object)menuCAnonStorey76.serializedProperty
            });
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            // ISSUE: reference to a compiler-generated field
            SearchFilter filter = new SearchFilter()
            {
                classNames = new string[1] {
                    menuCAnonStorey76.typeName
                }
            };

            hierarchyProperty.SetSearchFilter(filter);
            hierarchyProperty.Reset();
            while (hierarchyProperty.Next((int[])null))
            {
                // ISSUE: reference to a compiler-generated field
                genericMenu.AddItem(new GUIContent(hierarchyProperty.name), (hierarchyProperty.instanceID == num ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
                {
                    (object)hierarchyProperty.instanceID,
                    (object)menuCAnonStorey76.serializedProperty
                });
            }
            // ISSUE: reference to a compiler-generated field
            int classId = BaseObjectTools.StringToClassID(menuCAnonStorey76.typeName);

            if (classId > 0)
            {
                foreach (BuiltinResource builtinResource in EditorGUIUtility.GetBuiltinResourceList(classId))
                {
                    // ISSUE: reference to a compiler-generated field
                    genericMenu.AddItem(new GUIContent(builtinResource.m_Name), (builtinResource.m_InstanceID == num ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
                    {
                        (object)builtinResource.m_InstanceID,
                        (object)menuCAnonStorey76.serializedProperty
                    });
                }
            }
            genericMenu.AddSeparator(string.Empty);
            // ISSUE: reference to a compiler-generated method
            genericMenu.AddItem(new GUIContent("Create New..."), false, new GenericMenu.MenuFunction(menuCAnonStorey76.\u003C\u003Em__10A));
            genericMenu.DropDown(buttonRect);
        }
Esempio n. 31
0
        public override void FetchData()
        {
            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, 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 (SceneHierarchyWindow.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 void DoGUI(ASHistoryWindow parentWin, Rect theRect, bool focused)
        {
            if (ms_Styles == null)
            {
                ms_Styles = new Styles();
            }
            this.m_ScreenRect = theRect;
            Hashtable hashtable = new Hashtable();

            foreach (UnityEngine.Object obj2 in Selection.objects)
            {
                hashtable.Add(obj2.GetInstanceID(), null);
            }
            this.m_FileViewControlID = GUIUtility.GetControlID(ms_FileViewHash, FocusType.Passive);
            this.KeyboardGUI(parentWin);
            focused &= GUIUtility.keyboardControl == this.m_FileViewControlID;
            HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
            int  num2     = property.CountRemaining(this.m_ExpandedArray);
            int  num3     = !this.DeletedItemsToggle ? 0 : this.m_DelPVstate.lv.totalRows;
            Rect viewRect = new Rect(0f, 0f, 1f, (((num2 + 2) + num3) * m_RowHeight) + 16f);

            this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect);
            theRect.width         = (viewRect.height <= this.m_ScreenRect.height) ? theRect.width : (theRect.width - 18f);
            int count = Mathf.RoundToInt((this.m_ScrollPosition.y - 6f) - m_RowHeight) / Mathf.RoundToInt(m_RowHeight);

            if (count > num2)
            {
                count = num2;
            }
            else if (count < 0)
            {
                count = 0;
                this.m_ScrollPosition.y = 0f;
            }
            float      y        = 0f;
            GUIContent content  = new GUIContent();
            Event      current  = Event.current;
            GUIStyle   s        = new GUIStyle(ms_Styles.label);
            Texture2D  textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);

            y = (count * m_RowHeight) + 3f;
            float endOffset = this.m_ScreenRect.height + this.m_ScrollPosition.y;
            Rect  position  = new Rect(0f, y, theRect.width, m_RowHeight);

            if ((current.type == EventType.MouseDown) && position.Contains(current.mousePosition))
            {
                this.SelType = SelectionType.All;
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.ScrollTo(0f);
                parentWin.DoLocalSelectionChange();
                current.Use();
            }
            content = new GUIContent("Entire Project")
            {
                image = textured
            };
            int baseIndent = (int)this.m_BaseIndent;

            s.padding.left = 3;
            if (Event.current.type == EventType.Repaint)
            {
                s.Draw(position, content, false, false, this.SelType == SelectionType.All, focused);
            }
            y += m_RowHeight + 3f;
            property.Reset();
            property.Skip(count, this.m_ExpandedArray);
            while (property.Next(this.m_ExpandedArray) && (y <= endOffset))
            {
                int instanceID = property.instanceID;
                position = new Rect(0f, y, theRect.width, m_RowHeight);
                if (Event.current.type == EventType.Repaint)
                {
                    content.text   = property.name;
                    content.image  = property.icon;
                    baseIndent     = (int)(this.m_BaseIndent + (this.m_Indent * property.depth));
                    s.padding.left = baseIndent;
                    bool on = hashtable.Contains(instanceID);
                    s.Draw(position, content, false, false, on, focused);
                }
                if (property.hasChildren)
                {
                    bool flag2 = property.IsExpanded(this.m_ExpandedArray);
                    GUI.changed = false;
                    Rect rect3 = new Rect((this.m_BaseIndent + (this.m_Indent * property.depth)) - this.m_FoldoutSize, y, this.m_FoldoutSize, m_RowHeight);
                    flag2 = GUI.Toggle(rect3, flag2, GUIContent.none, ms_Styles.foldout);
                    if (GUI.changed)
                    {
                        if (Event.current.alt)
                        {
                            this.SetExpandedRecurse(instanceID, flag2);
                        }
                        else
                        {
                            this.SetExpanded(instanceID, flag2);
                        }
                    }
                }
                if (((current.type == EventType.MouseDown) && (Event.current.button == 0)) && position.Contains(Event.current.mousePosition))
                {
                    GUIUtility.keyboardControl = this.m_FileViewControlID;
                    if (Event.current.clickCount == 2)
                    {
                        AssetDatabase.OpenAsset(instanceID);
                        GUIUtility.ExitGUI();
                    }
                    else if (position.Contains(current.mousePosition))
                    {
                        this.SelectionClick(property);
                    }
                    current.Use();
                }
                y += m_RowHeight;
            }
            y += 3f;
            this.DoDeletedItemsGUI(parentWin, theRect, s, y, endOffset, focused);
            GUI.EndScrollView();
            switch (current.type)
            {
            case EventType.MouseDown:
                if ((current.button == 0) && this.m_ScreenRect.Contains(current.mousePosition))
                {
                    GUIUtility.hotControl = this.m_FileViewControlID;
                    current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == this.m_FileViewControlID)
                {
                    if (this.m_ScreenRect.Contains(current.mousePosition))
                    {
                        Selection.activeObject = null;
                    }
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                break;
            }
            this.HandleFraming();
        }
		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);
				}
			}
		}
Esempio n. 35
0
        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;

                if (!skipHiddenPackages)
                {
                    property.SetSearchFilter(new SearchFilter {
                        skipHidden = false
                    });
                }

                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);
        }
		private HierarchyProperty GetLast()
		{
			HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
			int count = hierarchyProperty.CountRemaining(this.m_ExpandedArray);
			hierarchyProperty.Reset();
			if (hierarchyProperty.Skip(count, this.m_ExpandedArray))
			{
				return hierarchyProperty;
			}
			return null;
		}
        // Returns number of rows in search result
        int InitializeSearchResults(HierarchyProperty property, int minAllowedDepth)
        {
            // Search setup
            const bool kShowItemHasChildren = false;
            const int  kItemDepth           = 0;
            int        currentSceneHandle   = -1;
            int        row           = 0;
            var        searchFilter  = SearchableEditorWindow.CreateFilter(searchString, (SearchableEditorWindow.SearchMode)m_SearchMode);
            var        searchContext = (SearchService.HierarchySearchContext)m_SearchSessionHandler.context;

            searchContext.filter       = searchFilter;
            searchContext.rootProperty = property;

            m_SearchSessionHandler.BeginSearch(searchString);

            var headerRows = new List <int>();

            while (property.NextWithDepthCheck(null, minAllowedDepth))
            {
                if (!m_SearchSessionHandler.Filter(m_SearchString, property))
                {
                    property.SetFilteredVisibility(false);
                    continue;
                }

                property.SetFilteredVisibility(true);
                var item = EnsureCreatedItem(row);
                // Add scene headers when encountering a new scene (and it's not a header in itself)
                if (AddSceneHeaderToSearchIfNeeded(item, property, ref currentSceneHandle))
                {
                    row++;
                    headerRows.Add(row);

                    if (property.isSceneHeader)
                    {
                        continue;                  // no need to add it
                    }
                    item = EnsureCreatedItem(row); // prepare for item below
                }
                InitTreeViewItem(item, property, kShowItemHasChildren, kItemDepth);
                row++;
            }

            m_SearchSessionHandler.EndSearch();

            int numRows = row;

            // Now sort scene section
            if (headerRows.Count > 0)
            {
                int currentSortStart = headerRows[0];
                for (int i = 1; i < headerRows.Count; i++)
                {
                    int count = headerRows[i] - currentSortStart - 1;
                    m_ListOfRows.Sort(currentSortStart, count, new TreeViewItemAlphaNumericSort());
                    currentSortStart = headerRows[i];
                }

                // last section
                m_ListOfRows.Sort(currentSortStart, numRows - currentSortStart, new TreeViewItemAlphaNumericSort());
            }


            return(numRows);
        }
		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;
		}
        private void AssetViewKeyboard()
        {
            switch (Event.current.keyCode)
            {
            case KeyCode.KeypadEnter:
            case KeyCode.Return:
                if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    this.OpenAssetSelection();
                    GUIUtility.ExitGUI();
                }
                break;

            case KeyCode.UpArrow:
            {
                Event.current.Use();
                HierarchyProperty firstSelected = this.GetFirstSelected();
                if (firstSelected != null)
                {
                    if (firstSelected.instanceID != this.GetFirst().instanceID)
                    {
                        if (firstSelected.Previous(this.m_ExpandedArray))
                        {
                            UnityEngine.Object pptrValue = firstSelected.pptrValue;
                            this.SelectionClick(firstSelected);
                            this.FrameObject(pptrValue);
                        }
                    }
                    else
                    {
                        this.SelType      = SelectionType.All;
                        Selection.objects = new UnityEngine.Object[0];
                        this.ScrollTo(0f);
                    }
                }
                break;
            }

            case KeyCode.DownArrow:
            {
                Event.current.Use();
                HierarchyProperty lastSelected = this.GetLastSelected();
                if ((Application.platform != RuntimePlatform.OSXEditor) || !Event.current.command)
                {
                    if (lastSelected != null)
                    {
                        if (lastSelected.instanceID == this.GetLast().instanceID)
                        {
                            this.SelType      = SelectionType.DeletedItemsRoot;
                            Selection.objects = new UnityEngine.Object[0];
                            this.ScrollToDeletedItem(-1);
                        }
                        else if (lastSelected.Next(this.m_ExpandedArray))
                        {
                            UnityEngine.Object target = lastSelected.pptrValue;
                            this.SelectionClick(lastSelected);
                            this.FrameObject(target);
                        }
                    }
                }
                else
                {
                    this.OpenAssetSelection();
                    GUIUtility.ExitGUI();
                }
                break;
            }

            case KeyCode.RightArrow:
            {
                HierarchyProperty activeSelected = this.GetActiveSelected();
                if (activeSelected != null)
                {
                    this.SetExpanded(activeSelected.instanceID, true);
                }
                break;
            }

            case KeyCode.LeftArrow:
            {
                HierarchyProperty property = this.GetActiveSelected();
                if (property != null)
                {
                    this.SetExpanded(property.instanceID, false);
                }
                break;
            }

            case KeyCode.Home:
                if (this.GetFirst() != null)
                {
                    Selection.activeObject = this.GetFirst().pptrValue;
                    this.FrameObject(Selection.activeObject);
                }
                break;

            case KeyCode.End:
                if (this.GetLast() != null)
                {
                    Selection.activeObject = this.GetLast().pptrValue;
                    this.FrameObject(Selection.activeObject);
                }
                break;

            case KeyCode.PageUp:
            {
                Event.current.Use();
                if (OSX)
                {
                    this.m_ScrollPosition.y -= this.m_ScreenRect.height;
                    if (this.m_ScrollPosition.y < 0f)
                    {
                        this.m_ScrollPosition.y = 0f;
                    }
                    break;
                }
                HierarchyProperty first = this.GetFirstSelected();
                if (first == null)
                {
                    if (this.GetFirst() != null)
                    {
                        Selection.activeObject = this.GetFirst().pptrValue;
                        this.FrameObject(Selection.activeObject);
                    }
                    break;
                }
                for (int i = 0; i < (this.m_ScreenRect.height / m_RowHeight); i++)
                {
                    if (!first.Previous(this.m_ExpandedArray))
                    {
                        first = this.GetFirst();
                        break;
                    }
                }
                UnityEngine.Object obj4 = first.pptrValue;
                this.SelectionClick(first);
                this.FrameObject(obj4);
                break;
            }

            case KeyCode.PageDown:
                Event.current.Use();
                if (!OSX)
                {
                    HierarchyProperty last = this.GetLastSelected();
                    if (last == null)
                    {
                        if (this.GetLast() != null)
                        {
                            Selection.activeObject = this.GetLast().pptrValue;
                            this.FrameObject(Selection.activeObject);
                        }
                        break;
                    }
                    for (int j = 0; j < (this.m_ScreenRect.height / m_RowHeight); j++)
                    {
                        if (!last.Next(this.m_ExpandedArray))
                        {
                            last = this.GetLast();
                            break;
                        }
                    }
                    UnityEngine.Object obj5 = last.pptrValue;
                    this.SelectionClick(last);
                    this.FrameObject(obj5);
                    break;
                }
                this.m_ScrollPosition.y += this.m_ScreenRect.height;
                break;

            default:
                return;
            }
            Event.current.Use();
        }
		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;
		}
Esempio n. 41
0
            internal static bool Filter(string query, HierarchyProperty objectToFilter, SearchContext context)
            {
                var activeEngine = k_EngineImp.activeSearchEngine;

                return(activeEngine.Filter(query, objectToFilter, context));
            }
 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);
 }
        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);
            }
        }
        public override bool IsRenamingItemAllowed(TreeViewItem item)
        {
            IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);

            return((!hierarchyProperty.Find(item.id, null) || hierarchyProperty.isMainRepresentation) && item.parent != null);
        }
Esempio n. 45
0
 private void InitTreeViewItem(GameObjectTreeViewItem item, HierarchyProperty property, bool itemHasChildren, int itemDepth)
 {
     InitTreeViewItem(item, property.instanceID, property.GetScene(), IsSceneHeader(property), property.colorCode, property.pptrValue, itemHasChildren, itemDepth);
 }
Esempio n. 46
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;

            this.m_RootItem = new TreeViewItem(this.m_RootInstanceID, depth, null, AssetsTreeViewDataSource.CreateDisplayName(this.m_RootInstanceID));
            if (!base.showRootItem)
            {
                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.showRootItem) ? 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);
        }
 public override void FetchData()
 {
     int depth = -1;
     base.m_RootItem = new TreeViewItem(0x3c34eb12, depth, null, "InvisibleRoot");
     this.SetExpanded(base.m_RootItem.id, true);
     List<int> allowedInstanceIDs = ObjectSelector.get.allowedInstanceIDs;
     HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
     SearchFilter filter = new SearchFilter();
     filter.classNames = new string[] { "AudioMixerController" };
     property.SetSearchFilter(filter);
     List<AudioMixerController> list2 = new List<AudioMixerController>();
     while (property.Next(null))
     {
         AudioMixerController pptrValue = property.pptrValue as AudioMixerController;
         if (this.ShouldShowController(pptrValue, allowedInstanceIDs))
         {
             list2.Add(pptrValue);
         }
     }
     List<TreeViewItem> list3 = new List<TreeViewItem> {
         new TreeViewItem(TreeViewForAudioMixerGroup.kNoneItemID, 0, base.m_RootItem, TreeViewForAudioMixerGroup.s_NoneText)
     };
     foreach (AudioMixerController controller2 in list2)
     {
         list3.Add(this.BuildSubTree(controller2));
     }
     base.m_RootItem.children = list3;
     if (list2.Count == 1)
     {
         base.m_TreeView.data.SetExpandedWithChildren(base.m_RootItem, true);
     }
     base.m_NeedRefreshVisibleFolders = true;
 }
 private extern static void INTERNAL_CALL_GetScene(HierarchyProperty self, out Scene value);