Exemplo n.º 1
0
        private void CreateSubTree(FindUsagePathElement element, IEnumerable <AbstractUsageElement> data, int startId)
        {
            var fileNames     = new Dictionary <string, FindUsagePathElement>();
            var curFileNameId = 0;

            foreach (var usageElement in data)
            {
                FindUsagePathElement current = element;

                var filePath     = usageElement.FilePath;
                var dataFileName = filePath.Split('/').Last();
                if (!fileNames.ContainsKey(filePath))
                {
                    current = current.CreateChild(new FindUsagePathElement(curFileNameId++)
                    {
                        id   = startId++, displayName = dataFileName,
                        icon = (Texture2D)EditorGUIUtility.IconContent(usageElement.StartNodeImage).image
                    });
                    fileNames.Add(filePath, current);
                }
                else
                {
                    current = fileNames[filePath];
                }

                var pathLength = usageElement.Path.Length;
                for (int i = 0; i < pathLength; i++)
                {
                    var name = usageElement.Path[i];
                    if (i + 1 == pathLength)
                    {
                        var id = startId++;
                        findResultItems[id] = new FindUsagesTreeViewItem(usageElement.RootIndices[i], usageElement)
                        {
                            id          = id,
                            displayName = name,
                            icon        = (Texture2D)EditorGUIUtility.IconContent(usageElement.TerminalNodeImage).image
                        };
                        current.AddChild(findResultItems[id]);
                    }
                    else
                    {
                        var rootIndex = usageElement.RootIndices[i];
                        if (!current.HasChild(rootIndex))
                        {
                            current = current.CreateChild(new FindUsagePathElement(rootIndex)
                            {
                                id   = startId++, displayName = name,
                                icon = (Texture2D)EditorGUIUtility.IconContent(usageElement.NodeImage).image
                            });
                        }
                        else
                        {
                            current = current.GetChild(rootIndex);
                        }
                    }
                }
            }
        }
        private void CreateAnimationEventItem([NotNull] TreeViewItem animationTreeRoot,
                                              [NotNull] AbstractUsageElement animationElement,
                                              ref int id)
        {
            var findUsagesTreeViewItem = new FindUsagesTreeViewItem(id, animationElement)
            {
                id          = id,
                displayName = animationElement.FileName,
                icon        = (Texture2D)EditorGUIUtility.IconContent(animationElement.TerminalNodeImage)?.image
            };

            findResultItems[id] = findUsagesTreeViewItem;
            animationTreeRoot.AddChild(findUsagesTreeViewItem);
            id++;
        }
Exemplo n.º 3
0
        private TreeViewItem CreateScriptableObjectSubTree()
        {
            var scriptableObject = new FindUsagePathElement(2)
            {
                id = 3, displayName = "Scriptable Objects"
            };

            var startId = 2_000_000_000;

            foreach (var usageElement in myState.ScriptableObjectElements.ToArray())
            {
                var id = startId++;
                findResultItems[id] = new FindUsagesTreeViewItem(-1, usageElement)
                {
                    id          = id,
                    displayName = usageElement.FilePath,
                    icon        = (Texture2D)EditorGUIUtility.IconContent(usageElement.TerminalNodeImage).image
                };
                scriptableObject.AddChild(findResultItems[id]);
            }

            return(scriptableObject);
        }
        private void CreateAnimatorSubTree([NotNull] FindUsagePathElement findUsagePathElement,
                                           [NotNull] AnimatorElement animatorElement, ref int id)
        {
            var currentParent = findUsagePathElement;

            for (int i = 0, pathElementsLength = animatorElement.PathElements.Length; i < pathElementsLength; i++)
            {
                var icon = i == pathElementsLength - 1
                ? animatorElement.TerminalNodeImage
                : AnimatorElement.AnimatorStateMachineIcon;
                var findUsagesTreeViewItem = new FindUsagesTreeViewItem(id, animatorElement)
                {
                    id          = id,
                    displayName = animatorElement.PathElements[i],
                    icon        = (Texture2D)EditorGUIUtility.IconContent(icon).image
                };
                findResultItems[id] = findUsagesTreeViewItem;
                myAnimatorItemIdToPathElementsCount[id] = i + 1;
                currentParent.AddChild(findUsagesTreeViewItem);
                currentParent = findUsagesTreeViewItem;
                id++;
            }
        }