/
Veteread
/
Packer
Обзор
Документация
Войти
/
Veteread
/
Packer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
BlockSpawnSystem.cs
52 строки
2 KB
Veteread
upload files
04 май 2025, 10:49
04 май 2025, 10:49
a5dcff3
Код
Авторство
О чём код?
using UnityEngine; public class BlockSpawnSystem : MonoBehaviour { [SerializeField] private Transform[] spawnPoints; [SerializeField] private float selectionRadius = 1f; [SerializeField] private GameObject highlightPrefab; public Transform SelectedPoint { get; private set; } public void ShowSpawnPoints() { ClearHighlights(); foreach (var point in spawnPoints) { Instantiate(highlightPrefab, point.position, Quaternion.identity); } } public bool TrySelectPoint(Vector2 screenPos, Camera cam) { Vector2 worldPos = cam.ScreenToWorldPoint(screenPos); foreach (var point in spawnPoints) { if (Vector2.Distance(worldPos, point.position) <= selectionRadius) { SelectedPoint = point; ClearHighlights(); return true; } } return false; } private void ClearHighlights() { var highlights = GameObject.FindGameObjectsWithTag("SpawnPointHighlight"); foreach (var highlight in highlights) { Destroy(highlight); } } public Block SpawnBlock(GameObject prefab, Transform spawnPoint, PlayerBlockDropper controller) { var newBlock = Instantiate(prefab, spawnPoint.position, Quaternion.identity); var blockComponent = newBlock.GetComponent<Block>(); blockComponent.Initialize(controller, false); return blockComponent; } }