Мои Уведомления
Привет, !
Мой Аккаунт Мои Финансы Мои Подписки Мои Настройки Выход
Руководство API скрипты

SerializedProperty.GetFixedBufferElementAtIndex

Объявление

public SerializedProperty GetFixedBufferElementAtIndex(int index);

Описание

Возвращает элемент по указанному индексу в фиксированном буфере.

Смотрите так же: isFixedBuffer, fixedBufferSize.

using UnityEngine; using UnityEditor; [System.Serializable] public unsafe struct TestStruct { public fixed int intBuffer[7]; } public unsafe class TestScript : MonoBehaviour { public TestStruct testStruct; void Start() { fixed(int* buffer = testStruct.intBuffer) { for (int i = 0; i < 7; ++i) buffer[i] = 3 + i; } var so = new SerializedObject(this); var prop = so.FindProperty("testStruct.intBuffer"); Debug.Log("isFixedBuffer = " + prop.isFixedBuffer); Debug.Log("fixedBufferSize = " + prop.fixedBufferSize); var elemProp = prop.GetFixedBufferElementAtIndex(2); Debug.Log("GetFixedBufferElementAtIndex(2) = " + elemProp.intValue); elemProp.intValue = 42; so.ApplyModifiedProperties(); fixed(int* buffer = testStruct.intBuffer) { Debug.Log("intBuffer[2] = " + buffer[2]); } } }
Вы можете отблагодарить автора, за перевод документации на русский язык. ₽ Спасибо
API скрипты 2021.3