/
Jeero
/
ecsproto.unity
Обзор
Документация
Войти
/
Jeero
/
ecsproto.unity
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Runtime/ProtoUnityAction.cs
53 строки
2 KB
Gleb
unity 6.5 fix
20 июн 2026, 01:43
20 июн 2026, 01:43
76c875e
Код
Авторство
О чём код?
// ---------------------------------------------------------------------------- // Лицензия MIT-ZARYA // (c) 2025 Leopotam <leopotam@yandex.ru> // ---------------------------------------------------------------------------- using System.Runtime.CompilerServices; using UnityEngine; #if ENABLE_IL2CPP using Unity.IL2CPP.CompilerServices; #endif namespace Leopotam.EcsProto.Unity { #if ENABLE_IL2CPP [Il2CppSetOption (Option.NullChecks, false)] [Il2CppSetOption (Option.ArrayBoundsChecks, false)] #endif [DefaultExecutionOrder (100)] public abstract class ProtoUnityAction<T> : MonoBehaviour where T : struct { [SerializeField] string _senderName; [SerializeField] string _worldName; ProtoPool<T> _pool; GameObject _sender; EntityId _senderHash; [MethodImpl (MethodImplOptions.AggressiveInlining)] public string WorldName () => _senderName; [MethodImpl (MethodImplOptions.AggressiveInlining)] protected virtual bool IsValidForEvent () => ProtoUnityWorlds.Connected (); [MethodImpl (MethodImplOptions.AggressiveInlining)] protected GameObject Sender () => _sender; [MethodImpl (MethodImplOptions.AggressiveInlining)] public string SenderName () => _senderName; [MethodImpl (MethodImplOptions.AggressiveInlining)] protected EntityId SenderHash () => _senderHash; [MethodImpl (MethodImplOptions.AggressiveInlining)] protected ref T NewEvent () { if (_pool == null) { var world = ProtoUnityWorlds.Get (string.IsNullOrEmpty (_worldName) ? default : _worldName); _pool = (ProtoPool<T>) world.Pool (typeof (T)); _sender = gameObject; _senderHash = _sender.GetEntityId (); } _pool.NewEntity (out var e); return ref _pool.Get (e); } } }