Esempio n. 1
0
    //Unity GUI function
    public override void OnGUI(Rect _Position)
    {
        SplitAttribute separatorAttribute = (SplitAttribute)attribute;
        Color          tColorStore        = GUI.backgroundColor;

        GUI.backgroundColor = Color.green;

        if (separatorAttribute.Title == "")
        {
            _Position.height = 1;
            _Position.y     += 9;
            GUI.Box(_Position, "");
        }
        else
        {
            Vector2 textSize       = GUI.skin.label.CalcSize(new GUIContent(separatorAttribute.Title));
            float   separatorWidth = (_Position.width - textSize.x) / 2.0f - 5.0f;
            _Position.y += 9;

            GUI.Box(new Rect(_Position.xMin, _Position.yMin, separatorWidth, 1), "");
            GUI.Label(new Rect(_Position.xMin + separatorWidth + 5.0f, _Position.yMin - 8f, textSize.x, 20), separatorAttribute.Title);
            GUI.Box(new Rect(_Position.xMin + separatorWidth + 10.0f + textSize.x, _Position.yMin, separatorWidth, 1), "");
        }

        GUI.backgroundColor = tColorStore;
    }
        void Init(SerializedProperty value)
        {
            if (SerializedProperty.EqualContents(value, property))
            {
                return;
            }

            property = value;

            keys   = property.FindPropertyRelative(nameof(keys));
            values = property.FindPropertyRelative(nameof(values));

            split = attribute as SplitAttribute;

            list = new ReorderableList(property.serializedObject, keys, true, true, true, true);

            list.drawHeaderCallback = DrawHeader;

            list.onAddCallback    = Add;
            list.onRemoveCallback = Remove;

            list.elementHeightCallback = GetElementHeight;

            list.drawElementCallback = DrawElement;

            list.onReorderCallbackWithDetails += Reorder;
        }
Esempio n. 3
0
        public override string ToString()
        {
            var builder = new StringBuilder();

            if (ParentSplitAttributeValue != null)
            {
                builder.Append(string.Format("{0}: {1}", ParentSplitAttribute.ToString(), ParentSplitAttributeValue.ToString()));
            }
            else
            {
                builder.Append("N/A");
            }

            builder.Append(string.Format(", {0}% ({1}/{2}) / {3}", Probability * 100.0, Positive.Count, Sources.Count,
                                         Entropy));

            builder.Append(" -> ");
            if (SplitAttributeInformationGain > 0)
            {
                builder.Append(SplitAttribute.ToString());
            }
            else
            {
                builder.Append("N/A");
            }

            return(builder.ToString());
        }