привет короче есть такая система using System.Collections.Generic; using UnityEngine;…
- User
привет короче есть такая система using System.Collections.Generic; using UnityEngine;
public class ArrowManager : StaticInstance { [Header("Arrow Settings")] public GameObject arrowPrefab; // Префаб стрелочки private List activeArrows = new List();
/// <summary> /// Очищает все текущие стрелочки. /// </summary> public void ClearArrows() { foreach (var arrow in activeArrows) { Destroy(arrow); } activeArrows.Clear(); } /// <summary> /// Создаёт стрелочки для переданных целей. /// </summary> /// <param name="targets">Список GameObject, на которые нужно указать стрелками.</param> public void CreateArrows(List<GameObject> targets) { ClearArrows(); foreach (var target in targets) { if (target == null) continue; GameObject arrow = Instantiate(arrowPrefab, target.transform.position, Quaternion.identity); activeArrows.Add(arrow); } }} мне надо чтобы эта система была задействована в моих блюпринт штуках смотри типо показывается этап блюпринтов и надо найти все объекты драгабл обжект с такими же именами как в блюпринтах (имена могут повторятся) и на всех них заспавнить стрелку ну с помощью метода из стрелок манагенр. и также когда схвачу объект должны появится только стрелки на нужных блюпринтах куда этот объект можно поставить понял? вот коды using System.Collections.Generic; using AYellowpaper.SerializedCollections; using EasyButtons; using UnityEngine; using UnityEngine.Events;
public class BlueprintManager : StaticInstance { public List blueprints; public UnityEvent onAllBlueprintsFilled;
public int currentStageIndex = 0; public SerializedDictionary<int, List<Blueprint>> blueprintsByStage = new SerializedDictionary<int, List<Blueprint>>(); private int totalStages = 0; public void ClearAll() { blueprints.Clear(); blueprintsByStage.Clear(); currentStageIndex = 0; BlueprintUIManager.Instance.SetUIActive(false); } public void SubscribeAllBlueprints(List<DronePart> droneParts, bool showUI) { ClearAll(); // Подписываемся на события заполнения каждого блюпринта foreach (var dronePart in droneParts) { if (dronePart.TryGetComponent(out Blueprint blueprint)) { if (blueprint.stageIndex == -1) { Debug.LogError("Not signet blueprint", blueprint); } if (!blueprintsByStage.ContainsKey(blueprint.stageIndex)) { blueprintsByStage[blueprint.stageIndex] = new List<Blueprint>(); } blueprintsByStage[blueprint.stageIndex].Add(blueprint); // Подписываемся на событие заполнения блюпринта blueprint.OnBlueprintFilled += OnBlueprintFilled; // Устанавливаем видимость блюпринта в зависимости от текущего этапа if (blueprint.stageIndex == currentStageIndex) { blueprint.gameObject.SetActive(true); } else { blueprint.gameObject.SetActive(false); } blueprints.Add(blueprint); } } // Определяем общее количество этапов totalStages = blueprintsByStage.Keys.Count; BlueprintUIManager.Instance.SetUIActive(showUI); UpdateUI(); } private void OnBlueprintFilled(Blueprint bp) { NotifyExamManager(); // Проверяем, заполнены ли все блюпринты текущего этапа bool stageCompleted = true; foreach (Blueprint blueprint in blueprintsByStage[currentStageIndex]) { if (!blueprint.IsFilled) { stageCompleted = false; break; } } UpdateUI(); if (stageCompleted) { ProceedToNextStage(); } } [Button] private void ProceedToNextStage() { // Скрываем блюпринты предыдущего этапа foreach (Blueprint bp in blueprintsByStage[currentStageIndex]) { bp.gameObject.SetActive(false); } currentStageIndex++; // Проверяем, есть ли следующий этап if (blueprintsByStage.ContainsKey(currentStageIndex)) { // Показываем блюпринты нового этапа foreach (Blueprint bp in blueprintsByStage[currentStageIndex]) { bp.gameObject.SetActive(true); } UpdateUI(); } else { Debug.Log("Сборка завершена!"); onAllBlueprintsFilled.Invoke(); BlueprintUIManager.Instance.SetUIActive(false); } } private void NotifyExamManager() { ExamManager.Instance?.IncrementDetailCount(); } private void Start() { onAllBlueprintsFilled.AddListener(OnAllBlueprintsFilled); } private void OnAllBlueprintsFilled() { ExamManager.Instance?.EndExam(); } // Метод для обновления UI при инициализации private void UpdateUI() { int completedDetails = GetCompletedDetailsInCurrentStage(); int totalDetails = blueprintsByStage[currentStageIndex].Count; BlueprintUIManager.Instance.UpdateUI(totalStages, currentStageIndex + 1, completedDetails, totalDetails); } // Метод для получения количества заполненных деталей на текущем этапе private int GetCompletedDetailsInCurrentStage() { int count = 0; foreach (Blueprint bp in blueprintsByStage[currentStageIndex]) { if (bp.IsFilled) count++; } return count; } - Assistant
- User
да супер а теперь сделай так чтобы при старте или когда мы перестаем таскать система смотрела все наши блюпринты записывала все имена их, и потом находила на сцене все объекты DraggableObject смотрела какой у них имя детали и если воспадатает то записывала в список объектов и потом уже по этому списку создавала стрелки
- Assistant
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.