private static void AssignGroup(InspectorItemRenderer renderer, string currentGroup) { if(renderer.inspectorAttribute.group == "") { renderer.inspectorAttribute.group = currentGroup; } }
public MessageRenderer(InspectorItemRenderer inspectorItemRenderer, object caller, object classFieldBelongTo, InspectorItemRenderer[] otherRenderers = null) { MessageAttribute messageAttribute = AttributeHelper.GetAttribute<MessageAttribute>(inspectorItemRenderer.entityInfo); this.text = messageAttribute.text; this.method = messageAttribute.method; this.id = messageAttribute.id; this.value = messageAttribute.value; this.caller = caller; this.classFieldBelongTo = classFieldBelongTo; switch (messageAttribute.messageType) { case MessageType.Info: this.messageType = UnityEditor.MessageType.Info; break; case MessageType.Warning: this.messageType = UnityEditor.MessageType.Warning; break; case MessageType.Error: this.messageType = UnityEditor.MessageType.Error; break; } this.otherRenderers = otherRenderers; }
public FullObjectDecoratedRenderer(InspectorItemRenderer renderer, FullObjectRenderer contextRenderer) { this.renderer = renderer; this.contextRenderer = contextRenderer; groupName = renderer.inspectorAttribute.group; InitializeLayouts(); visibilitySetter = VisibilitySetter.GetVisibilitySetter(renderer, contextRenderer); InitializeMessageRenderers(); }
//// <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> protected override MessageRenderer GetMessageRenderer(InspectorItemRenderer renderer) { MessageRenderer result = null; MessageAttribute messageAttribute = AttributeHelper.GetAttribute<MessageAttribute>(renderer.entityInfo); if(messageAttribute != null) { result = new MessageRenderer(renderer, subtarget, subtarget, renderers.ToArray()); } return result; }
public VisibilitySetter(InspectorItemRenderer inspectorItemRenderer, object caller, object classFieldBelongTo, InspectorItemRenderer[] otherRenderers = null) { visibilityAttribute = AttributeHelper.GetAttribute<VisibilityAttribute>(inspectorItemRenderer.entityInfo); if(visibilityAttribute != null) { this.method = visibilityAttribute.method; this.id = visibilityAttribute.id; this.value = visibilityAttribute.value; } this.caller = caller; this.classFieldBelongTo = classFieldBelongTo; this.inspectorItemRenderer = inspectorItemRenderer; this.otherRenderers = otherRenderers; }
//// <summary> /// Gets the message renderer for <c>InspectorItemRenderer</c> with the attribute MessageAttribute. /// If the renderer belongs to the editor script, then the method specified in MessageAttribute /// is looked for in the editor script. /// </summary> /// <returns>The message renderer created to render MessageAttribute in the inspector.</returns> /// <param name="renderer">An item renderer.</param> protected override MessageRenderer GetMessageRenderer(InspectorItemRenderer renderer) { MessageRenderer result = null; MessageAttribute messageAttribute = AttributeHelper.GetAttribute<MessageAttribute>(renderer.entityInfo); if(messageAttribute != null) { object caller = serializedObject.targetObject; if(renderer.entityInfo.isMethod) { if(typeof(EasyEditorBase).IsAssignableFrom(renderer.entityInfo.methodInfo.DeclaringType)) { caller = editorScript; } } result = new MessageRenderer(renderer, caller, serializedObject.targetObject, renderers.ToArray()); } return result; }
/// <summary> /// Sets the visibility of a renderer based on the attribute [Visibility]. /// If VisibilityAttribute parameters id and value are not null, and the object with the id 'id' /// has the value 'value', then the renderer holding the attribute is visible, otherwise it is not display in the inspector. /// If method is not empty, then if the class where the visibility attribute is used has this function and this function return true, /// the renderer will be rendered. /// </summary> public static VisibilitySetter GetVisibilitySetter(InspectorItemRenderer renderer, FullObjectRenderer contextRenderer) { object caller = null; object classFieldBelongTo = null; FullObjectRenderer.GetContextualObjects(renderer, contextRenderer, out caller, out classFieldBelongTo); return new VisibilitySetter(renderer, caller, classFieldBelongTo, contextRenderer.renderers.ToArray()); }
private void SetEndLayout(InspectorItemRenderer renderer) { if(renderer.horizontalLayout == HorizontalLayout.EndHorizontal) { EditorGUILayout.EndHorizontal(); currentLayoutIsHorizontal = false; } if(renderer.verticalLayout == VerticalLayout.EndVertical) { EditorGUILayout.EndVertical(); } }
private void SetBeginLayout(InspectorItemRenderer renderer) { if(renderer.horizontalLayout == HorizontalLayout.BeginHorizontal) { EditorGUILayout.BeginHorizontal(); currentLayoutIsHorizontal = true; } if(renderer.verticalLayout == VerticalLayout.BeginVertical) { EditorGUILayout.BeginVertical(); } }
/// <summary> /// Gets the message renderer for <c>InspectorItemRenderer</c> with the attribute MessageAttribute. /// Since messages can be displayed based on other fields or condition external to a specific /// InspectorItemRenderer, the renderer in charge of rendering a group of renderers (like ScriptObjectRenderer or /// InlineClassRenderer) needs to implement this function. /// </summary> /// <returns>The message renderer created to render MessageAttribute in the inspector.</returns> /// <param name="renderer">An item renderer.</param> protected virtual MessageRenderer GetMessageRenderer(InspectorItemRenderer renderer) { return null; }
static public void GetContextualObjects(InspectorItemRenderer renderer, FullObjectRenderer contextRenderer, out object caller, out object classFieldBelongTo) { if(contextRenderer is InlineClassRenderer) { caller = ((InlineClassRenderer) contextRenderer).subtarget; classFieldBelongTo = ((InlineClassRenderer) contextRenderer).subtarget; } else if(contextRenderer is FullObjectRenderer) { caller = contextRenderer.serializedObject.targetObject; classFieldBelongTo = contextRenderer.serializedObject.targetObject; if(renderer.entityInfo.isMethod) { if(typeof(EasyEditorBase).IsAssignableFrom(renderer.entityInfo.methodInfo.DeclaringType)) { caller = ((ScriptObjectRenderer) contextRenderer).editorScript; } } } else { caller = null; classFieldBelongTo = null; } }
//// <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(); }