Moved changes to develop branch
@@ -203,6 +203,56 @@ namespace StereoKit
}
}
+ /// <summary>
+ /// The name and type of a Parameter on a Material
+ /// </summary>
+ public struct ParamInfo
+ {
+ /// <summary>
+ /// The name of the param
+ /// </summary>
+ public string Name;
+
+ /// <summary>
+ /// The type of the param
+ /// </summary>
+ public MaterialParam Type;
+ /// <summary>
+ /// Parameter Info constructor
+ /// </summary>
+ /// <param name="name">Name of the shader parameter.</param>
+ /// <param name="type">New type for the parameter.</param>
+ internal ParamInfo(string name, MaterialParam type)
+ {
+ Name = name;
+ Type = type;
+ }
+ }
+
+ /// <summary>Gets all shader parameters Name and Type</summary>
+ public IEnumerable<ParamInfo> GetAllParamsInfo()
+ {
+ var count = NativeAPI.material_get_param_count(_inst);
+ for (int i = 0; i < count; i++)
+ {
+ NativeAPI.material_get_param_info(_inst, i, out string name, out MaterialParam type);
+ yield return new ParamInfo(name, type);
+ }
+ }
+
+ /// <summary>Gets shader parameter Name and Type</summary>
+ /// <param name="index">Index of the shader parameter.</param>
+ public ParamInfo GetParamInfo(int index)
+ {
+ var count = NativeAPI.material_get_param_count(_inst);
+ if((count <= index) || index < 0)
+ {
+ throw new IndexOutOfRangeException("Param not found");
+ }
+ NativeAPI.material_get_param_info(_inst, index, out string name, out MaterialParam type);
+ return new ParamInfo(name, type);
+ }
+
/// <summary>Creates a new Material asset with the same shader and
/// properties! Draw calls with the new Material will not batch
/// together with this one.</summary>
