Exemple #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            VectorRotationAttribute at    = this.attribute as VectorRotationAttribute;
            bool               timescaled = at.Timescaled;
            double             scale      = LSEditorUtility.Scale(timescaled);
            SerializedProperty x          = property.FindPropertyRelative("x");
            SerializedProperty y          = property.FindPropertyRelative("y");

            double angleInRadians = Math.Atan2(y.longValue.ToDouble(), x.longValue.ToDouble());

            double angleInDegrees = (angleInRadians * 180d / Math.PI) * scale;

            height          = 15f;
            position.height = height;
            angleInDegrees  = (EditorGUI.DoubleField(position, "Angle", angleInDegrees)) / scale;

            double newAngleInRadians = angleInDegrees * Math.PI / 180d;

            if (Math.Abs(newAngleInRadians - angleInRadians) >= .001f)
            {
                long cos = FixedMath.Create(Math.Cos(newAngleInRadians));
                long sin = FixedMath.Create(Math.Sin(newAngleInRadians));
                x.longValue = cos;
                y.longValue = sin;
            }
        }
Exemple #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            FixedNumberAttribute a = ((FixedNumberAttribute)this.attribute);
            long orgValue          = property.longValue;
            long value             = orgValue;

            LSEditorUtility.DoubleField(
                position,
                label,
                ref value,
                a.Timescaled
                );
            if (a.Ranged)
            {
                if (value > a.Max)
                {
                    value = a.Max;
                }
                else if (value < a.Min)
                {
                    value = a.Min;
                }
            }
            if (orgValue != value)
            {
                property.longValue = value;
            }
        }
Exemple #3
0
        static LSScenePropertyDrawer()
        {
            List <Type> drawerTypes = LSEditorUtility.GetFilteredTypes(typeof(LSScenePropertyDrawer));

            foreach (Type type in drawerTypes)
            {
                LSScenePropertyDrawer drawer = (LSScenePropertyDrawer)Activator.CreateInstance(type);
                Type targetType = drawer.TargetType;
                MappedDrawers.Add(targetType, drawer);
            }
        }
        private static IEnumerable<LSScenePropertyDrawer> GetPropertyDrawers(SerializedProperty p)
        {
            Type propertyObjectType = LSEditorUtility.GetPropertyType(p);
            if (propertyObjectType == null)
                yield break;
            LSScenePropertyDrawer drawer = LSScenePropertyDrawer.GetDrawer(propertyObjectType);
            yield return drawer;
            IEnumerable<PropertyAttribute> propertyAttributes = LSEditorUtility.GetPropertyAttributes<PropertyAttribute>(p);
            foreach (PropertyAttribute propertyAttribute in propertyAttributes)
            {
                drawer = LSScenePropertyDrawer.GetDrawer(propertyAttribute.GetType());
                yield return drawer;
            }

        }