-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShaderExtension.cs
33 lines (29 loc) · 1.07 KB
/
ShaderExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using UnityEngine;
using UnityEngine.Rendering;
namespace Aya.Extension
{
public static class ShaderExtension
{
public static bool ContainsProperty(this Shader shader, string propertyName)
{
if (propertyName.EndsWith("_ST")) propertyName = propertyName.Replace("_ST", "");
for (var i = 0; i < shader.GetPropertyCount(); i++)
{
var name = shader.GetPropertyName(i);
if (name == propertyName) return true;
}
return false;
}
public static bool ContainsProperty(this Shader shader, string propertyName, ShaderPropertyType propertyType)
{
if (propertyName.EndsWith("_ST")) propertyName = propertyName.Replace("_ST", "");
for (var i = 0; i < shader.GetPropertyCount(); i++)
{
var name = shader.GetPropertyName(i);
var type = shader.GetPropertyType(i);
if (name == propertyName && type == propertyType) return true;
}
return false;
}
}
}