/
GeekNerd
/
ServerModelingProject
Обзор
Документация
Войти
/
GeekNerd
/
ServerModelingProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Assets/Scripts/UIEntities/DotButtonView.cs
52 строки
1 KB
Gorney-Alex
Init
30 май 2026, 19:05
30 май 2026, 19:05
3cdcc49
Код
Авторство
О чём код?
using System; using DataClasses; using Interfaces; using UnityEngine; using UnityEngine.UI; namespace UIEntities { public class DotButtonView : MonoBehaviour, IDotButtonView { public GameObject OwnerGameObject => gameObject; private Image _image; private RectTransform _rect; private Button _button; public void Init(BaseData baseData) { _rect = GetComponent<RectTransform>(); _image = GetComponent<Image>(); if (baseData is DotButtonData newData) { UpdateName(newData.StartName); _image.color = newData.Color; } } public void UpdatePosition(Vector2 newPosition) { _rect.anchoredPosition = newPosition; } public void UpdateName(string newName) { if (String.IsNullOrEmpty(newName)) return; gameObject.name = newName; } public Button GetButton() { if (_button == null) { _button = GetComponent<Button>(); } return _button; } } }