BattlehubCode / RTE_Docs

This is a repository for Runtime Editor documentation, discussion and tracking features and issues.
https://assetstore.unity.com/packages/tools/modeling/runtime-editor-64806
11 stars 0 forks source link

How to add TMP_FontAsset to Runtime Asset Library #82

Closed BattlehubCode closed 1 year ago

BattlehubCode commented 1 year ago

https://www.youtube.com/watch?v=MKcuSs4p5xs

At the twelfth second, you'll see how to add a custom implementation to the Persistent TMP_FontAsset. Copy and paste the code below

#if !RTSL_MAINTENANCE
using Battlehub.RTSL;
namespace TMPro.Battlehub.SL2
{
    [CustomImplementation]
    public partial class PersistentTMP_FontAsset<TID>
    {
        public override void ReadFrom(object obj)
        {
            var uo = obj as UnityEngine.Object;
            if (uo != null && !m_assetDB.IsStaticResourceID(ToID(uo)))
            {
                base.ReadFrom(obj);
            }
        }

        public override object WriteTo(object obj)
        {
            var uo = obj as UnityEngine.Object;
            if (uo != null && !m_assetDB.IsStaticResourceID(ToID(uo)))
            {
                return base.WriteTo(obj);
            }

            return obj;
        }

        public override void GetDeps(GetDepsContext<TID> context)
        {
            base.GetDeps(context);
        }

        public override void GetDepsFrom(object obj, GetDepsFromContext context)
        {
            var uo = obj as UnityEngine.Object;
            if (uo != null && !m_assetDB.IsStaticResourceID(ToID(uo)))
            {
                base.GetDepsFrom(obj, context);
            }
        }
    }
}
#endif