static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(LayerMask), new HashSet <string> { nameof(LayerMask.value) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(Renderer), new HashSet <string> { nameof(Renderer.sharedMaterials) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(Transform), new HashSet <string> { nameof(Transform.localPosition), nameof(Transform.localRotation), nameof(Transform.localScale) }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Transform), new HashSet <string> { nameof(Transform.hasChanged) }); ReflectedPropertyBagUtils.SetIncludedProperties(typeof(RectTransform), new HashSet <string> { nameof(RectTransform.pivot), nameof(RectTransform.anchorMin), nameof(RectTransform.anchorMax), nameof(RectTransform.sizeDelta), nameof(RectTransform.anchoredPosition) }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(RectTransform), new HashSet <string> { "drivenByObject" }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(MeshFilter), new HashSet <string> { nameof(MeshFilter.mesh) }); }
void CreateProperty <TContainer, TValue>(IMemberInfo member, ReflectedPropertyBag <TContainer> propertyBag) { if (typeof(TValue).IsPointer) { return; } var arrayProperty = ReflectedPropertyBagUtils.TryCreateUnityObjectArrayProperty <TContainer, TValue>(member); if (arrayProperty != null) { propertyBag.AddProperty(arrayProperty); return; } var listProperty = ReflectedPropertyBagUtils.TryCreateUnityObjectListProperty <TContainer, TValue>(member); if (listProperty != null) { propertyBag.AddProperty(listProperty); return; } var property = ReflectedPropertyBagUtils.TryCreateUnityObjectProperty <TContainer>(member); if (property != null) { propertyBag.AddProperty(property); return; } propertyBag.AddProperty(new ReflectedMemberProperty <TContainer, TValue>(member, member.Name)); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(Collider), new HashSet <string> { nameof(Collider.sharedMaterial) }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Collider), new HashSet <string> { nameof(Collider.contactOffset), nameof(Collider.material) }); ReflectedPropertyBagUtils.SetIncludedProperties(typeof(BoxCollider), new HashSet <string> { nameof(BoxCollider.center) }); ReflectedPropertyBagUtils.SetIncludedProperties(typeof(CapsuleCollider), new HashSet <string> { nameof(CapsuleCollider.center) }); ReflectedPropertyBagUtils.SetIncludedProperties(typeof(SphereCollider), new HashSet <string> { nameof(SphereCollider.center) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Canvas), new HashSet <string> { nameof(Canvas.worldCamera) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(UnityObject), new HashSet <string> { nameof(UnityObject.hideFlags) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Animator), new HashSet <string> { nameof(Animator.playbackTime), nameof(Animator.fireEvents), nameof(Animator.stabilizeFeet), nameof(Animator.feetPivotActive), nameof(Animator.speed), nameof(Animator.layersAffectMassCenter), nameof(Animator.logWarnings) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(MonoBehaviour), new HashSet <string> { nameof(MonoBehaviour.enabled) }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(MonoBehaviour), new HashSet <string> { nameof(MonoBehaviour.useGUILayout), #if UNITY_EDITOR nameof(MonoBehaviour.runInEditMode) #endif }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(Light), new HashSet <string> { nameof(Light.color), #if UNITY_EDITOR nameof(Light.areaSize) #endif }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Light), new HashSet <string> { nameof(Light.layerShadowCullDistances) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIncludedProperties(typeof(Camera), new HashSet <string> { nameof(Camera.backgroundColor), nameof(Camera.sensorSize), nameof(Camera.lensShift) }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Camera), new HashSet <string> { nameof(Camera.pixelRect), nameof(Camera.aspect) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(TMP_TextInfo), new HashSet <string> { nameof(TMP_TextInfo.wordInfo), nameof(TMP_TextInfo.characterInfo), nameof(TMP_TextInfo.linkInfo), nameof(TMP_TextInfo.lineInfo), nameof(TMP_TextInfo.pageInfo), nameof(TMP_TextInfo.meshInfo), "m_CachedMeshInfo" }); ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(TMP_CharacterInfo), new HashSet <string> { nameof(TMP_CharacterInfo.textElement) }); }
static void Initialize() { ReflectedPropertyBagUtils.SetIgnoredProperties(typeof(Rigidbody), new HashSet <string> { nameof(Rigidbody.maxDepenetrationVelocity), nameof(Rigidbody.freezeRotation), nameof(Rigidbody.detectCollisions), nameof(Rigidbody.solverIterations), nameof(Rigidbody.sleepThreshold), nameof(Rigidbody.maxAngularVelocity), nameof(Rigidbody.solverVelocityIterations), #if !UNITY_2021_1_OR_NEWER #pragma warning disable 618 nameof(Rigidbody.sleepVelocity), nameof(Rigidbody.sleepAngularVelocity) #pragma warning restore 618 #endif }); }
public IPropertyBag <TContainer> CreatePropertyBag <TContainer>() { if (!RuntimeTypeInfoCache <TContainer> .IsContainerType || RuntimeTypeInfoCache <TContainer> .IsObjectType) { throw new InvalidOperationException("Invalid container type."); } if (typeof(TContainer).IsArray) { if (typeof(TContainer).GetArrayRank() != 1) { throw new InvalidOperationException("Properties does not support multidimensional arrays."); } return((IPropertyBag <TContainer>)m_CreateListPropertyBagMethod.MakeGenericMethod(typeof(TContainer), typeof(TContainer).GetElementType()).Invoke(this, new object[0])); } if (typeof(TContainer).IsGenericType && (typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(List <>)) || typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(IList <>)))) { return((IPropertyBag <TContainer>)m_CreateListPropertyBagMethod.MakeGenericMethod(typeof(TContainer), typeof(TContainer).GetGenericArguments().First()).Invoke(this, new object[0])); } if (typeof(TContainer).IsGenericType && (typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(HashSet <>)) || typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(ISet <>)))) { return((IPropertyBag <TContainer>)m_CreateSetPropertyBagMethod.MakeGenericMethod(typeof(TContainer), typeof(TContainer).GetGenericArguments().First()).Invoke(this, new object[0])); } if (typeof(TContainer).IsGenericType && (typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(Dictionary <,>)) || typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(IDictionary <,>)))) { var types = typeof(TContainer).GetGenericArguments().ToArray(); return((IPropertyBag <TContainer>)m_CreateDictionaryPropertyBagMethod.MakeGenericMethod(typeof(TContainer), types[0], types[1]).Invoke(this, new object[0])); } if (typeof(TContainer).IsGenericType && typeof(TContainer).GetGenericTypeDefinition().IsAssignableFrom(typeof(KeyValuePair <,>))) { var types = typeof(TContainer).GetGenericArguments().ToArray(); return((IPropertyBag <TContainer>)m_CreateKeyValuePairPropertyBagMethod.MakeGenericMethod(types[0], types[1]).Invoke(this, new object[0])); } var propertyBag = new ReflectedPropertyBag <TContainer>(); foreach (var(member, nameOverride) in ReflectedPropertyBagUtils.GetPropertyMembers(typeof(TContainer))) { IMemberInfo info; var memberName = string.IsNullOrEmpty(nameOverride) ? member.Name : nameOverride; switch (member) { case FieldInfo field: info = new FieldMember(field, memberName); break; case PropertyInfo property: info = new PropertyMember(property, memberName); break; default: throw new InvalidOperationException(); } m_CreatePropertyMethod.MakeGenericMethod(typeof(TContainer), info.ValueType).Invoke(this, new object[] { info, propertyBag }); } return(propertyBag); }