public VertigoMaterial GetInstance(string materialName, IList <string> keywords) { if (keywords != null) { SortKeywords(keywords); } if (sharedMaterialMap.TryGetValue(materialName, out List <VertigoMaterial> materials)) { for (int i = 0; i < materials.Count; i++) { if (KeywordsMatch(keywords, materials[i])) { return(materials[i].GetInstance()); } } VertigoMaterial retn = CreateMaterial(materialName, keywords); if (retn.material == null) { return(null); } materials.Add(retn); return(retn.GetInstance()); } else { VertigoMaterial retn = CreateMaterial(materialName, keywords); materials = new List <VertigoMaterial>(); materials.Add(retn); sharedMaterialMap.Add(materialName, materials); return(retn.GetInstance()); } }
private static bool KeywordsMatch(IList <string> keywords, VertigoMaterial material) { if (keywords == null) { if (material.keywords == null || material.keywords.Length == 0) { return(true); } return(false); } if (material.keywords == null) { return(keywords.Count == 0); } if (keywords.Count != material.keywords.Length) { return(false); } for (int i = 0; i < material.keywords.Length; i++) { if (keywords[i] != material.keywords[i]) { return(false); } } return(true); }
public VertigoMaterial(Material material) { this.material = material; this.keywords = null; this.isActive = true; this.parent = null; this.instances = null; }
public VertigoMaterial GetInstance() { VertigoMaterial retn = null; if (instances.Count > 0) { retn = instances.RemoveLast(); } else { retn = new VertigoMaterial(this); } retn.isActive = true; return(retn); }
public VertigoMaterial GetInstance(string materialName, string keyword0 = null, string keyword1 = null, string keyword2 = null, string keyword3 = null) { if (keyword0 != null) { s_Keywords.Add(keyword0); } if (keyword1 != null) { s_Keywords.Add(keyword1); } if (keyword2 != null) { s_Keywords.Add(keyword2); } if (keyword3 != null) { s_Keywords.Add(keyword3); } VertigoMaterial retn = GetInstance(materialName, s_Keywords); s_Keywords.Clear(); return(retn); }
public void FillRoundedRect(float x, float y, float width, float height, float rTL, float rTR, float rBL, float rBR, VertigoMaterial material = null) { material = material ?? fillMaterial; int pathId = shapeGenerator.RoundedRect(x, y, width, height, rTL, rTR, rBL, rBR); geometryGenerator.Fill(shapeGenerator, new RangeInt(pathId, 1), defaultShapeMode, geometryCache); batcher.AddDrawCall(geometryCache, new RangeInt(geometryCache.shapeCount - 1, 1), material, renderState); }
internal VertigoMaterial(VertigoMaterial parent) { this.material = new Material(parent.material); this.keywords = parent.keywords; this.parent = parent; }