Add default values initialization for structures and new array entries when resizing
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEngine;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Editors
|
||||
@@ -48,6 +49,15 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
Array.Copy(array, oldSize - 1, newValues, i, 1);
|
||||
}
|
||||
}
|
||||
else if (newSize > 0)
|
||||
{
|
||||
// Initialize new entries with default values
|
||||
var defaultValue = TypeUtils.GetDefaultValue(new ScriptType(elementType));
|
||||
for (int i = 0; i < newSize; i++)
|
||||
{
|
||||
newValues.SetValue(defaultValue, i);
|
||||
}
|
||||
}
|
||||
|
||||
SetValue(newValues);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
}
|
||||
else if (newSize > 0)
|
||||
{
|
||||
// Fill new entries
|
||||
// Fill new entries with default value
|
||||
var defaultValue = Scripting.TypeUtils.GetDefaultValue(ElementType);
|
||||
for (int i = oldSize; i < newSize; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user