Ejemplo n.º 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            var lengthProperty = property.GetMemberProperty <Timer>(t => t.length);
            var timer          = SerializedPropertyHelper.GetValue(fieldInfo, property) as Timer;

            if (timer != null && timer.IsRunning)
            {
                GUI.color = Color.cyan;
                Rect progressPosition = position.Right(-EditorGUIUtility.labelWidth);
                progressPosition.width *= timer.Progress;
                GUI.Box(progressPosition, GUIContent.none);
                GUI.color = Color.white;
            }

            EditorGUI.PropertyField(position, lengthProperty, label);
            UnitDrawer.DrawUnit(position, "seconds", new None());

            if (lengthProperty.floatValue < 0.0f)
            {
                lengthProperty.floatValue = 0.0f;
                property.serializedObject.ApplyModifiedProperties();
            }
        }
Ejemplo n.º 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);
            EditorGUI.PropertyField(position, property, label);

            var exponentInfoAttribute = attribute as ExponentInfoAttribute;

            string exp = string.Empty;

            if (property.propertyType == SerializedPropertyType.Integer)
            {
                var value = property.intValue;
                if (Mathf.Abs(value) < 1000)
                {
                    return;
                }

                exp = value.ToString("G2", CultureInfo.InvariantCulture);
            }
            else if (property.propertyType.Equals("long"))
            {
                var value = property.longValue;
                if (Mathf.Abs(value) < 1000)
                {
                    return;
                }

                exp = value.ToString("G2", CultureInfo.InvariantCulture);
            }
            else if (property.propertyType == SerializedPropertyType.Float)
            {
                var value = property.floatValue;
                if (Mathf.Abs(value) < 1000 &&
                    value.ToString(CultureInfo.InvariantCulture).Length < 5)
                {
                    return;
                }

                exp = value.ToString("G2", CultureInfo.InvariantCulture);
            }
            else if (property.type.Equals("double"))
            {
                var value = property.doubleValue;
                if (System.Math.Abs(value) < 1000 &&
                    value.ToString(CultureInfo.InvariantCulture).Length < 5)
                {
                    return;
                }

                exp = value.ToString("G2", CultureInfo.InvariantCulture);
            }

            UnitDrawer.DrawUnit(position, exp, exponentInfoAttribute.style);
        }
Ejemplo n.º 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            var lengthProperty = property.GetMemberProperty <Timer.Duration>(d => d.length);

            EditorGUI.PropertyField(position, lengthProperty, label);
            UnitDrawer.DrawUnit(position, "seconds", EditorStyles.centeredGreyMiniLabel);

            if (lengthProperty.floatValue < Mathf.Epsilon)
            {
                lengthProperty.floatValue = Mathf.Epsilon;
                property.serializedObject.ApplyModifiedProperties();
            }
        }