< Summary

Class:DrawIfAttribute
Assembly:MainAttributesRuntime
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/Attributes/Runtime/DrawIfAttribute.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:40
Line coverage:0% (0 of 8)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
DrawIfAttribute(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/Attributes/Runtime/DrawIfAttribute.cs

#LineLine coverage
 1using UnityEngine;
 2using System;
 3
 4/// <summary>
 5/// Draws the field/property ONLY if the compared property compared by the comparison type with the value of comparedVal
 6/// Based on: https://forum.unity.com/threads/draw-a-field-only-if-a-condition-is-met.448855/
 7/// </summary>
 8[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
 9public class DrawIfAttribute : PropertyAttribute
 10{
 11    #region Fields
 12
 013    public string comparedPropertyName { get; private set; }
 014    public object comparedValue { get; private set; }
 015    public DisablingType disablingType { get; private set; }
 16
 17    /// <summary>
 18    /// Types of comperisons.
 19    /// </summary>
 20    public enum DisablingType
 21    {
 22        ReadOnly = 2,
 23        DontDraw = 3
 24    }
 25
 26    #endregion
 27
 28    /// <summary>
 29    /// Only draws the field only if a condition is met. Supports enum and bools.
 30    /// </summary>
 31    /// <param name="comparedPropertyName">The name of the property that is being compared (case sensitive).</param>
 32    /// <param name="comparedValue">The value the property is being compared to.</param>
 33    /// <param name="disablingType">The type of disabling that should happen if the condition is NOT met. Defaulted to D
 034    public DrawIfAttribute(string comparedPropertyName, object comparedValue, DisablingType disablingType = DisablingTyp
 35    {
 036        this.comparedPropertyName = comparedPropertyName;
 037        this.comparedValue = comparedValue;
 038        this.disablingType = disablingType;
 039    }
 40}