示例#1
0
        void FillHierarchy(List <GameObjectReference> gameObjectReferences, GameObjectReference gameObjectReference, GameObject hierarchyMemberPrefab, int depth = -1)
        {
            if (!gameObjectReference.matchesSearchQuery)
            {
                return;
            }

            depth++;

            var hierarchyMemberGameObject = GameObject.Instantiate(hierarchyMemberPrefab, hierarchyContentTransform);

            instantiatedHierarchyObjects.Add(hierarchyMemberGameObject);

            var hierarchyMemberText = hierarchyMemberGameObject.GetComponent <Text>();

            hierarchyMemberText.text = $" {Utilities.Indent(depth)}{gameObjectReference.GetName()}";

            var hierarchyMemberButton = hierarchyMemberGameObject.GetComponent <Button>();

            hierarchyMemberButton.onClick.AddListener(() =>
            {
                gameObjectReference.expanded = !gameObjectReference.expanded;
                FillHierarchy(gameObjectReferences);
                InstantiateComponents(gameObjectReference);
            });

            if (gameObjectReference.expanded)
            {
                foreach (var child in gameObjectReference.childGameObjectReferences)
                {
                    FillHierarchy(gameObjectReferences, child, hierarchyMemberPrefab, depth);
                }
            }
        }
示例#2
0
        static string GetGameObjectDebugString(GameObjectReference gameObjectReference, int i = 0)
        {
            var debugString = $"{Indent(i)}{gameObjectReference.GetName()}:\n";

            if (gameObjectReference.childGameObjectReferences.Any())
            {
                debugString += $"{Indent(i + 1)}Child Objects:\n";
                foreach (var item in gameObjectReference.childGameObjectReferences)
                {
                    debugString += GetGameObjectDebugString(item, i + 2);
                }
            }

            if (gameObjectReference.childComponentReferences.Any())
            {
                debugString += $"{Indent(i + 1)}Components:\n";
                foreach (var item in gameObjectReference.childComponentReferences)
                {
                    debugString += GetComponentDebugString(item, i + 2);
                }
            }

            return(debugString);
        }