Пример #1
0
        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;
        }
Пример #2
0
        //// <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);
        }
Пример #3
0
        //// <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);
        }
Пример #4
0
 public MessageRenderer(MessageAttribute messageAttribute, object caller, object classFieldBelongTo, InspectorItemRenderer[] otherRenderers = null)
 {
     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;
 }