public LevelEditorPropertyData(ExposedProperty property, IExposedToLevelEditor exposedComponent) { id = property.ID; value = exposedComponent?.GetValue(property.ID); // Used for Unity references. They need to be converted to a simple component. type = property.Type; if (property is ExposedArray array) { if (array.ElementType.IsSubclassOf(typeof(Component))) { if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(List <>))) { //type = typeof(List<>).MakeGenericType(typeof(Component)); throw new NotSupportedException($"List<{array.ElementType}> is not supported. For collection of Unity objects, use array instead."); } else { type = typeof(Component).MakeArrayType(); } } } else { // type = property.Type.IsSubclassOf(typeof(Component)) ? typeof(Component) : property.Type; type = ComponentDataWrapper.IsComponent(property.Type) ? typeof(ComponentDataWrapper) : property.Type; } typeName = type.FullName; }
protected LevelEditorInspectorField GetField <T>(ExposedProperty property, string label) { LevelEditorInspectorField field = GetField <T>(property); field.Label = label; return(field); }
protected LevelEditorInspectorField GetField <T>(ExposedProperty property) { if (TryGetField <T>(property, out LevelEditorInspectorField field)) { return(field); } throw new ArgumentException($"There's no InspectorField that supports type '{typeof(T).FullName}'."); }
protected bool TryGetField <T>(ExposedProperty property, string label, out LevelEditorInspectorField field) { if (TryGetField <T>(property, out field)) { field.Label = label; return(true); } else { return(false); } }
public virtual bool SupportsType(ExposedProperty property) { //TODO: Support arrays return(SupportsType(property.Type, property.Type.IsArray)); }
protected bool TryAddField <T>(ExposedProperty property, string label) { return(TryGetField <T>(property, label, out _)); }
protected bool TryAddField <T>(ExposedProperty property) { return(TryGetField <T>(property, out _)); }
protected void AddField <T>(ExposedProperty property, string label) { GetField <T>(property, label); }
protected void AddField <T>(ExposedProperty property) { GetField <T>(property); }