Version: 2017.2 (switch to 2017.3b)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

SerializedProperty.GetFixedBufferElementAtIndex

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public method GetFixedBufferElementAtIndex(index: int): SerializedProperty;
public SerializedProperty GetFixedBufferElementAtIndex(int index);

Description

Returns the element at the specified index in the fixed buffer.

no example available in JavaScript
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]); } } }

Did you find this page useful? Please give it a rating: