❔ Referring to a file in C#

Hello, I have a file (.shader) in my Solution directory, however I'm trying to refer to it in code, I have tried
void Start()
{
fileEntries = Directory.GetFiles(@"D:\BorderLandsMod");
foreach (String file in fileEntries)
{
if (file == "LoveShader.shader")
{
Shader shader = file;
}
else
{
return;
}
}
void Start()
{
fileEntries = Directory.GetFiles(@"D:\BorderLandsMod");
foreach (String file in fileEntries)
{
if (file == "LoveShader.shader")
{
Shader shader = file;
}
else
{
return;
}
}
However, that returns Cannot implicitly convert from type 'string' to 'unityEngine.Shader. Any help would be relaly appreciated!
6 Replies
Buddy
Buddy2y ago
Shader is a shader and file is a String https://docs.unity3d.com/ScriptReference/Shader.html
HyperSilver69
HyperSilver69OP2y ago
I know, so this approach doesn't work. I'm looking for alternatives
Buddy
Buddy2y ago
and finding shaders by name (Find method).
HyperSilver69
HyperSilver69OP2y ago
I'm not trying to search for it in a unity project It's a C# project that uses the Unity namespace so .Find is of no use to me
Buddy
Buddy2y ago
try
- read file content into variable foo

Material bar = new Material(foo);
- read file content into variable foo

Material bar = new Material(foo);
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server