rj-action-library/Runtime/Shading/Shaders/Shaders.cs

55 lines
1.1 KiB
C#

using Godot;
using System.Reflection;
using System.Collections.Generic;
namespace Rokojori
{
public class Shaders
{
public static List<UniformMember> GetUniformMembers( Shader shader )
{
var list = new List<UniformMember>();
var uniforms = shader.GetShaderUniformList();
foreach ( var u in uniforms )
{
var d = u.AsGodotDictionary();
var member = new UniformMember();
member.name = d[ "name" ].AsString();
member.type = (Variant.Type) d[ "type" ].AsInt32();
member.hint = (PropertyHint) d[ "hint" ].AsInt32();
member.hintString = d[ "hint_string" ].AsString();
member.usage = d[ "usage" ].AsInt32();
list.Add( member );
}
return list;
}
public static List<string> GetUniformNames( Shader shader )
{
var list = new List<string>();
var uniforms = shader.GetShaderUniformList();
foreach ( var p in uniforms )
{
var d = p.AsGodotDictionary();
var name = d[ "name" ].ToString();
list.Add( name );
}
return list;
}
}
}