Gets the full path to a resource file.
To create a function that creates a material type from vertex and fragment shaders:
private void CreateMaterialType(string name, string vertexShaderPath, string fragmentShaderPath)
{
var materialTypeLibrary = studio.ActiveProject.MaterialTypeLibrary;
var materialType = studio.ActiveProject.CreateProjectItem<MaterialType>(
materialTypeLibrary.GenerateUniqueChildName(name), materialTypeLibrary);
string vertexShaderSource = File.ReadAllText(vertexShaderPath);
var vertexShader = materialType.Children.OfType<VertexShader>().First();
var vertexShaderSourceFile = vertexShader.Get(vertexShader.PropertyTypes.ShaderSourceFile);
var vertexShaderSourceFileFileSystemPath = vertexShaderSourceFile.FileSystemPath;
if (File.Exists(vertexShaderSourceFileFileSystemPath))
{
File.WriteAllText(vertexShaderSourceFileFileSystemPath, vertexShaderSource);
}
string fragmentShaderSource = File.ReadAllText(fragmentShaderPath);
var fragmentShader = materialType.Children.OfType<FragmentShader>().First();
var fragmentShaderSourceFile = fragmentShader.Get(fragmentShader.PropertyTypes.ShaderSourceFile);
var fragmentShaderSourceFileFileSystemPath = fragmentShaderSourceFile.FileSystemPath;
if (File.Exists(fragmentShaderSourceFileFileSystemPath))
{
File.WriteAllText(fragmentShaderSourceFileFileSystemPath, fragmentShaderSource);
}
var materialLibrary = studio.ActiveProject.MaterialLibrary;
var material = studio.ActiveProject.CreateProjectItem<Material>(
materialLibrary.GenerateUniqueChildName(name + "Material"), materialLibrary);
material.Set(material.PropertyTypes.MaterialType, materialType);
}