/
Bruhh
/
Simulator
Обзор
Документация
Войти
/
Bruhh
/
Simulator
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
PCSocket.cs
63 строки
2 KB
Bruhh
upload files
04 дек 2025, 08:25
04 дек 2025, 08:25
838886c
Код
Авторство
О чём код?
using UnityEngine; public class PCSocket : MonoBehaviour { public string acceptedComponentType; public PCComponent installedComponent; public Vector3 installOffset; public Material highlightMaterial; private Material originalMaterial; private Renderer socketRenderer; private void Awake() { socketRenderer = GetComponent<Renderer>(); originalMaterial = socketRenderer.material; } public bool CanAcceptComponent(PCComponent component) { return installedComponent == null && component.componentType == acceptedComponentType; } public void InstallComponent(PCComponent component) { component.GetComponent<Rigidbody>().isKinematic = true; component.transform.SetParent(transform); component.transform.localScale = Vector3.one; component.transform.localPosition = installOffset; component.transform.localRotation = Quaternion.Euler(component.installedRotation); component.OnInstalled(); installedComponent = component; OnStopHighlight(); } public void RemoveComponent() { if (installedComponent != null) { installedComponent.ResetComponent(); installedComponent = null; } } public void OnHighlight() { if (socketRenderer != null && highlightMaterial != null) { socketRenderer.material = highlightMaterial; } } public void OnStopHighlight() { if (socketRenderer != null && originalMaterial != null) { socketRenderer.material = originalMaterial; } } }