private bool TryCacheDebuggerDisplay(IObjectValueRole <TValue> valueRole, IMetadataTypeLite instanceType,
                                             IUserDataHolder userDataHolder)
        {
            // Special case. Replace with a second dictionary or whatever if we need to handle more types
            if (valueRole.ValueReference is NamedReferenceDecorator <TValue> reference && reference.IsNameFromValue &&
                instanceType.FullName == "UnityEngine.GameObject")
            {
                userDataHolder.PutData(ourDebuggerDisplayStringKey, GameObjectDebuggerDisplayStringWithoutName);
                return(true);
            }

            // DebuggerDisplayAttribute is inherited. This is important for applying a debug string on Behaviour, and
            // having it used in custom MonoBehaviour classes
            var current = instanceType;

            while (current != null)
            {
                if (myDebuggerDisplayValues.TryGetValue(current.GetGenericTypeDefinition().FullName,
                                                        out var displayString))
                {
                    userDataHolder.PutData(ourDebuggerDisplayStringKey, displayString);
                    return(true);
                }

                current = current.BaseType;
            }

            return(false);
        }
Exemplo n.º 2
0
        public override bool IsAvailable(IUserDataHolder cache)
        {
            var isAvailable = base.IsAvailable(cache);

            if (isAvailable)
            {
                cache.PutData(InstanceKey, this);
            }
            return(isAvailable);
        }
Exemplo n.º 3
0
 public void PutData <T>(Key <T> key, T val) where T : class
 {
     _dataHolder.PutData(key, val);
 }
 public override bool IsAvailable(IUserDataHolder cache)
 {
     var isAvailable = base.IsAvailable(cache);
     if (isAvailable) cache.PutData(InstanceKey, this);
     return isAvailable;
 }