Exemplo n.º 1
0
        public void InfiniteNumberTest1()
        {
            //Ulong Maxvalue = 18446744073709551615
            InfiniteNumber n1 = new InfiniteNumber(1234567890);

            Assert.AreEqual(n1.ToString(), "1234567890");
        }
Exemplo n.º 2
0
        public void InfiniteNumberTest6()
        {
            InfiniteNumber n1 = new InfiniteNumber();

            n1.O_Add(9);

            Assert.AreEqual(n1.ToString(), "9");
        }
Exemplo n.º 3
0
        public void InfiniteNumberTest2()
        {
            //Ulong Maxvalue = 18446744073709551615
            //                  1000000000000000000
            //                   999999999999999999

            InfiniteNumber n1 = new InfiniteNumber();

            n1.O_Add(999999999999999999);
            Assert.AreEqual(n1.ToString(), "999999999999999999");
        }
Exemplo n.º 4
0
        public void InfiniteNumberTest4()
        {
            //Ulong Maxvalue = 18446744073709551615
            //                  1000000000000000000
            //                   999999999999999999

            InfiniteNumber n1 = new InfiniteNumber();

            n1.O_Add(999999999999999999);
            n1.O_Add(1);
            Console.WriteLine(n1);
            Assert.AreEqual(n1.ToString(), "1000000000000000000");
        }
    public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
    {
        // get serialized property
        SerializedProperty valueStringProp = property.FindPropertyRelative("serializedValue");

        // get tooltip
        string           tooltipText = null;
        TooltipAttribute tooltip     = GetTooltip(fieldInfo, true);

        if (tooltip != null)
        {
            tooltipText = tooltip.tooltip;
        }

        // cache rect width
        float rectWidth = rect.width;

        // show label as int field for scroll capabilities
        rect.width = EditorGUIUtility.labelWidth + 2;

        EditorGUI.BeginChangeCheck();
        long scrollVal = EditorGUI.LongField(rect, new GUIContent(property.displayName, tooltipText), 0);

        if (EditorGUI.EndChangeCheck())
        {
            InfiniteNumber nb = new InfiniteNumber(valueStringProp.stringValue);
            nb += scrollVal;

            valueStringProp.stringValue = nb.ToString();
        }

        rect.x    += rect.width;
        rect.width = rectWidth - rect.width;

        // show text area
        EditorGUI.BeginProperty(rect, label, property);
        {
            EditorGUI.BeginChangeCheck();
            string newVal = EditorGUI.DelayedTextField(rect, new GUIContent(""), InfiniteNumber.FormatString(valueStringProp.stringValue),
                                                       EditorStyles.numberField);
            if (EditorGUI.EndChangeCheck())
            {
                valueStringProp.stringValue = newVal;
            }
        }
        EditorGUI.EndProperty();
    }