예제 #1
0
        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;
        }
예제 #2
0
 private bool IsSoftMaskable(TextEffectBase target)
 {
     #if ENABLE_SOFT_MASK
     return(!target.gameObject.Ancestors().OfComponent <SoftMask>().IsEmpty());
     #else
     return(false);
     #endif
 }
예제 #3
0
        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);
            }
        }