using UnityEngine; using UnityEngine.UI; using TMPro; using System.Collections.Generic; using System.Linq; using UnityEditor.Experimental.GraphView; using static TreeEditor.TreeEditorHelper; public class Explorer : MonoBehaviour { public class FileNode { public string name; public NodeType type; public List children = new List(); public FileNode parent; public FileNode(string name, NodeType type, FileNode parent = null) { this.name = name; this.type = type; this.parent = parent; } } public AppLayer notepadsapplayer; public enum NodeType { Drive, Folder, File } [Header("Настройки UI")] public GameObject filePrefab; public Transform contentParent; public Button backButton; [Header("Спрайты иконок")] public Sprite driveSprite; public Sprite folderSprite; public Sprite fileSprite; private FileNode root; private FileNode currentDir; void Awake() { BuildFileSystem(); } void Start() { if (backButton != null) backButton.onClick.AddListener(GoBack); OpenDirectory(root); } void OpenDirectory(FileNode node) { currentDir = node; RefreshUI(); } void GoBack() { if (currentDir != null && currentDir.parent != null) { OpenDirectory(currentDir.parent); } } void RefreshUI() { foreach (Transform child in contentParent) Destroy(child.gameObject); if (backButton != null) backButton.interactable = currentDir.parent != null; foreach (var file in currentDir.children) { GameObject item = Instantiate(filePrefab, contentParent); TMP_Text txt = item.GetComponentInChildren(); txt.text = file.name; Image[] images = item.GetComponentsInChildren(); foreach (var img in images) { if (img.gameObject.name == "Icon") { img.sprite = GetSprite(file.type); break; } } // Вешаем логику клика Button btn = item.GetComponent