//// <summary> /// Gets the message renderer for <c>InspectorItemRenderer</c> with the attribute MessageAttribute. /// </summary> /// <returns>The message renderer created to render MessageAttribute in the inspector.</returns> /// <param name="renderer">An item renderer.</param> /// <param name="contextRenderer">The context in which the renderer is rendered.</param> public static MessageRenderer[] GetMessageRenderers(InspectorItemRenderer renderer, FullObjectRenderer contextRenderer) { List <MessageRenderer> result = new List <MessageRenderer>(); object caller = null; object classFieldBelongTo = null; FullObjectRenderer.GetContextualObjects(renderer, contextRenderer, out caller, out classFieldBelongTo); MessageAttribute[] messageAttributes = AttributeHelper.GetAttributes <MessageAttribute>(renderer.entityInfo); if (messageAttributes != null) { foreach (MessageAttribute messageAttribute in messageAttributes) { result.Add(new MessageRenderer(messageAttribute, caller, classFieldBelongTo, contextRenderer.renderers.ToArray())); } } return(result.ToArray()); }
static private Type GetDefaultRendererTypeForField(FieldInfo fieldInfo) { Type result = null; IEnumerable <Type> collection = Utils.FindSubClassesOf <InspectorItemRenderer>(); foreach (Type inspectorItemRendererType in collection) { RenderTypeAttribute[] renderTypeAttributes = AttributeHelper.GetAttributes <RenderTypeAttribute>(inspectorItemRendererType); if (renderTypeAttributes != null) { foreach (RenderTypeAttribute renderTypeAttribute in renderTypeAttributes) { if (fieldInfo.FieldType == renderTypeAttribute.type || renderTypeAttribute.type.IsAssignableFrom(fieldInfo.FieldType)) { result = inspectorItemRendererType; break; } } } } if (result == null && FieldInfoHelper.HasSerializableAttribute(fieldInfo.FieldType)) { result = typeof(SerializedFieldRenderer); } if (result == null) { Debug.LogWarning("The field '" + fieldInfo.Name + "' does not fit any renderer. If you want this type of field to be rendered, ensure that " + "a class inheriting from InspectorItemRenderer have the attribute RenderType with the type of the field as argument OR " + "add [Inspector(rendererType = \" class name of the renderer to use\" on top of the field, Ex : [Inspector(rendererType = \"SerializedFieldRenderer\"]."); } return(result); }