public object ResolvedMemberObject() { if (targetObject == null || targetObject.Equals(null)) { return(null); } //if snapshot not null, means at least one time this has been evaluated if (_resolvedMemberObject != null && !_resolvedMemberObject.Equals(null) && snapshot != null) { return(_resolvedMemberObject); } var result = targetObject; //if is gameobject, resolve path and final component type if (targetObject is GameObject) { var leafGameObject = (GameObject)targetObject; if (!string.IsNullOrEmpty(transformHierarchyPath)) { var leafTransform = UnityObjectUtility.ResolveTransformPath(leafGameObject.transform, transformHierarchyPath); leafGameObject = leafTransform != null ? leafTransform.gameObject : null; } result = leafGameObject != null?leafGameObject.GetComponent(declaringType) : null; } result = ReflectionTools.GetRelativeMemberParent(result, parameterName); return(_resolvedMemberObject = result); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var att = (EnabledIfAttribute)attribute; var parent = ReflectionTools.GetRelativeMemberParent(property.serializedObject.targetObject, property.propertyPath); var member = ReflectionTools.RTGetFieldOrProp(parent.GetType(), att.propertyName); var value = (int)System.Convert.ChangeType(member.RTGetFieldOrPropValue(parent), typeof(int)); enable = value == att.value; GUI.enabled = enable; EditorGUI.PropertyField(position, property); GUI.enabled = true; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var att = (CallbackAttribute)attribute; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(position, property); if (EditorGUI.EndChangeCheck()) { var parent = ReflectionTools.GetRelativeMemberParent(property.serializedObject.targetObject, property.propertyPath); var method = parent.GetType().RTGetMethod(att.methodName); method.Invoke(parent, null); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var att = (EnabledIfAttribute)attribute; var parent = ReflectionTools.GetRelativeMemberParent(property.serializedObject.targetObject, property.propertyPath); var member = ReflectionTools.RTGetFieldOrProp(parent.GetType(), att.propertyName); if (member != null) { var objectValue = member.RTGetFieldOrPropValue(parent); var intValue = 1; if (property.propertyType == SerializedPropertyType.ObjectReference) { intValue = objectValue != null ? 1 : 0; } else { intValue = (int)System.Convert.ChangeType(objectValue, typeof(int)); } GUI.enabled = intValue == att.value; } EditorGUI.PropertyField(position, property); GUI.enabled = true; }