Fixed bug where rendering inspectors for scripts that contain uninitialized List<T>s causes crashes #257
|
@ -23,6 +23,7 @@ public class RaccoonShowcase : Script
|
||||||
[Range(-5, 5)]
|
[Range(-5, 5)]
|
||||||
public List<int> intList = new List<int>(new int[] { 2, 8, 2, 6, 8, 0, 1 });
|
public List<int> intList = new List<int>(new int[] { 2, 8, 2, 6, 8, 0, 1 });
|
||||||
public List<Light.Type> enumList = new List<Light.Type>(new Light.Type[] { Light.Type.Point, Light.Type.Directional, Light.Type.Ambient });
|
public List<Light.Type> enumList = new List<Light.Type>(new Light.Type[] { Light.Type.Point, Light.Type.Directional, Light.Type.Ambient });
|
||||||
|
public List<int> nullList;
|
||||||
public FontAsset fontAsset;
|
public FontAsset fontAsset;
|
||||||
public MeshAsset mesh;
|
public MeshAsset mesh;
|
||||||
public MaterialAsset matAsset;
|
public MaterialAsset matAsset;
|
||||||
|
|
|
@ -189,6 +189,12 @@ namespace SHADE
|
||||||
System::Type^ listType = field->FieldType->GenericTypeArguments[0];
|
System::Type^ listType = field->FieldType->GenericTypeArguments[0];
|
||||||
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field);
|
RangeAttribute^ rangeAttrib = hasAttribute<RangeAttribute^>(field);
|
||||||
System::Collections::IList^ iList = safe_cast<System::Collections::IList^>(field->GetValue(object));
|
System::Collections::IList^ iList = safe_cast<System::Collections::IList^>(field->GetValue(object));
|
||||||
|
if (iList == nullptr)
|
||||||
|
{
|
||||||
|
// Create if the list does not exist
|
||||||
|
iList = safe_cast<System::Collections::IList^>(System::Activator::CreateInstance(field->FieldType));
|
||||||
|
field->SetValue(object, iList);
|
||||||
|
}
|
||||||
|
|
||||||
if (SHEditorUI::CollapsingHeader(Convert::ToNative(field->Name), &isHovered))
|
if (SHEditorUI::CollapsingHeader(Convert::ToNative(field->Name), &isHovered))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue