Skip to content

Commit

Permalink
Fix reflection on structs
Browse files Browse the repository at this point in the history
  • Loading branch information
deccer committed Dec 4, 2022
1 parent 4521203 commit 1763cd9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/EngineKit/Graphics/VirtualFileShaderIncludeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ public class VirtualFileShaderIncludeHandler : IShaderIncludeHandler
var glsl = new StringBuilder();
glsl.AppendLine($"struct {includeType.Name}");
glsl.AppendLine("{");
var members = includeType
.GetFields(BindingFlags.Public)
.Select(field => new { Name = field.Name, Type = field.FieldType })
.Concat(includeType.GetProperties(BindingFlags.Public | BindingFlags.Instance).Select(property => new { Name = property.Name, Type = property.PropertyType }));
var fields = includeType
.GetFields(BindingFlags.Public | BindingFlags.Instance)
.Select(field => new { Name = field.Name, Type = field.FieldType });

var properties = includeType
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Select(property => new { property.Name, Type = property.PropertyType });

var members = fields.Concat(properties);
foreach (var member in members)
{
glsl.AppendLine($" {ToGlslType(member.Type)} {member.Name};");
Expand Down

0 comments on commit 1763cd9

Please sign in to comment.