public static MaterialManager GetInstance(NTexture texture, string shaderName, string[] keywords)
{
NTexture rootTexture = texture.root;
if (rootTexture.materialManagers == null)
rootTexture.materialManagers = new Dictionary<string, MaterialManager>();
string key = shaderName;
if (keywords != null)
{
//对于带指定关键字的,目前的设计是不参加共享材质了,因为逻辑会变得更复杂
key = shaderName + "_" + _gCounter++;
}
MaterialManager mm;
if (!rootTexture.materialManagers.TryGetValue(key, out mm))
{
mm = new MaterialManager(rootTexture);
mm.shaderName = shaderName;
mm._keywords = keywords;
rootTexture.materialManagers.Add(key, mm);
}
return mm;
}