public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var contextPathAttribute = this.attribute as ContextPathAttribute; var pathDisplayName = contextPathAttribute != null && !string.IsNullOrEmpty(contextPathAttribute.PathDisplayName) ? contextPathAttribute.PathDisplayName : "Path"; var targetObject = property.serializedObject.targetObject; // Check if target object has a custom context type. var contextTypeProperty = property.serializedObject.FindProperty("ContextType"); var dataContextType = contextTypeProperty != null ? ReflectionUtils.FindType(contextTypeProperty.stringValue) : ContextTypeEditorUtils.GetContextType((Component)targetObject); if (dataContextType != this.currentDataContextType) { this.dataContextPaths = ContextTypeCache.GetPaths( dataContextType, contextPathAttribute != null ? contextPathAttribute.Filter : ContextMemberFilter.All); this.currentDataContextType = dataContextType; } var hasCustomPath = this.HasCustomPath(property.propertyPath); property.stringValue = PathPopup( position, property.stringValue, this.dataContextPaths, pathDisplayName, ref hasCustomPath); this.hasPropertyCustomPath[property.propertyPath] = hasCustomPath; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var contextPathAttribute = this.attribute as ContextPathAttribute; var pathDisplayName = contextPathAttribute != null && !string.IsNullOrEmpty(contextPathAttribute.PathDisplayName) ? contextPathAttribute.PathDisplayName : "Path"; var targetObject = property.serializedObject.targetObject; var contextType = ContextTypeEditorUtils.GetContextType((Component)targetObject); var hasCustomPath = this.HasCustomPath(property.propertyPath); property.stringValue = PathPopup( position, property.stringValue, ContextTypeCache.GetPaths( contextType, contextPathAttribute != null ? contextPathAttribute.Filter : ContextMemberFilter.All), pathDisplayName, ref hasCustomPath); this.hasPropertyCustomPath[property.propertyPath] = hasCustomPath; }