Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        /// <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()));
        }
        public FullObjectDecoratedRenderer(InspectorItemRenderer renderer, FullObjectRenderer contextRenderer)
        {
            this.renderer = renderer;
            this.contextRenderer = contextRenderer;

            groupName = renderer.inspectorAttribute.group;
            InitializeLayouts();

            visibilitySetter = VisibilitySetter.GetVisibilitySetter(renderer, contextRenderer);
            InitializeMessageRenderers();
        }
        public FullObjectDecoratedRenderer(InspectorItemRenderer renderer, FullObjectRenderer contextRenderer)
        {
            this.renderer        = renderer;
            this.contextRenderer = contextRenderer;

            groupName = renderer.inspectorAttribute.group;
            InitializeLayouts();

            visibilitySetter = VisibilitySetter.GetVisibilitySetter(renderer, contextRenderer);
            InitializeMessageRenderers();
        }
Exemplo n.º 5
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>
        /// <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());
        }
Exemplo n.º 6
0
        /// <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());
        }
Exemplo n.º 7
0
        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;
            }
        }
Exemplo n.º 8
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>
        /// <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();
        }