using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Reflection;
using System.Linq;
using System;
public static class ShaderUtilInterface
{
public static Dictionary<string, MethodInfo> methods = new Dictionary<string, MethodInfo>();
static ShaderUtilInterface() {
var asm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetTypes().Any(t => t.Name == "ShaderUtil"));
if (asm != null)
{
var tp = asm.GetTypes().FirstOrDefault(t => t.Name == "ShaderUtil");
foreach (var method in tp.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static))
{
methods[method.Name] = method;
}
}
}
public static int GetPropertyCount(this Material shader)
{
return Call<int>("GetPropertyCount", shader.shader);
}
public static string GetPropertyName(this Material shader, int index)
{
return Call<string>("GetPropertyName", shader.shader, index);
}
public static int GetPropertyType(this Material shader, int index)
{
return Call<int>("GetPropertyType", shader.shader, index);
}
public static T Call<T>(string name, params object[] parameters)
{
return (T)methods[name].Invoke(null, parameters);
}
}
ShaderUtilInterface
最新推荐文章于 2024-01-05 12:14:54 发布