Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the visibility of a renderer based on the attribute [Visibility(string id, object value)]. If the object with the id 'id'
        /// has the value 'value', the the renderer holding the attribute is visible, otherwise it is not display in the inspector.
        /// </summary>
        private void SetVisibility()
        {
            foreach (InspectorItemRenderer renderer in renderers)
            {
                FieldInfo fieldInfo = null;

                if (renderer.entityInfo.isField)
                {
                    fieldInfo = renderer.entityInfo.fieldInfo;
                }

                if (fieldInfo != null)
                {
                    VisibilityAttribute visibilityAttribute = AttributeHelper.GetAttribute <VisibilityAttribute>(fieldInfo);
                    if (visibilityAttribute != null)
                    {
                        InspectorItemRenderer conditionalRenderer = LookForRenderer(visibilityAttribute.id);
                        if (conditionalRenderer != null && conditionalRenderer.entityInfo.isField)
                        {
                            if (visibilityAttribute.value.Equals(conditionalRenderer.entityInfo.fieldInfo.GetValue(_serializedObject.targetObject)))
                            {
                                ShowRenderer(renderer.GetIdentifier());
                            }
                            else
                            {
                                HideRenderer(renderer.GetIdentifier());
                            }
                        }
                        else
                        {
                            Debug.LogWarning("The identifier " + visibilityAttribute.id + " was not found in the list of renderers, or this renderer " +
                                             "was not initialized from a field. Ensure that the id parameter of the attribute Visibility refers to the id of a field " +
                                             "(name of the field if you did not specify explicitly the id of the field in [Inspector(id = \"...\").");
                        }
                    }
                }
            }
        }