public void Apply(TextEffectBase target) { Release(target); var softMaskable = IsSoftMaskable(target); var components = UnityUtility.GetComponents <TextEffectBase>(target.gameObject) .Where(x => x.Alive) .ToArray(); var cacheKey = GetCacheKey(components, softMaskable); var material = GetMaterial(cacheKey, components, softMaskable); if (material != null) { if (!reference.ContainsKey(material)) { reference.Add(material, new List <TextEffectBase>()); } if (target.Alive) { reference[material].Add(target); } } target.Text.material = material; }
private bool IsSoftMaskable(TextEffectBase target) { #if ENABLE_SOFT_MASK return(!target.gameObject.Ancestors().OfComponent <SoftMask>().IsEmpty()); #else return(false); #endif }
private void Release(TextEffectBase target) { var material = target.Text.material; if (!reference.ContainsKey(material)) { return; } reference[material].Remove(target); if (reference[material].IsEmpty()) { var item = materials.FirstOrDefault(x => x.Value == material); reference.Remove(material); materials.Remove(item.Key); target.Text.material = null; UnityUtility.SafeDelete(material); } }