Kaynağa Gözat

Minor tweaks to follow engine guidelines

marco.bellan 9 yıl önce
ebeveyn
işleme
52970a388f
33 değiştirilmiş dosya ile 240 ekleme ve 130 silme
  1. 0 7
      Source/BansheeCore/Source/Win32/BsWin32Platform.cpp
  2. 1 1
      Source/BansheeEditor/Include/BsGUIFloatField.h
  3. 1 1
      Source/BansheeEditor/Include/BsGUIIntField.h
  4. 2 2
      Source/BansheeEditor/Include/BsGUISliderField.h
  5. 2 3
      Source/BansheeEditor/Source/BsGUIFloatField.cpp
  6. 1 1
      Source/BansheeEditor/Source/BsGUIIntField.cpp
  7. 1 2
      Source/BansheeEditor/Source/BsGUISliderField.cpp
  8. 10 8
      Source/BansheeEngine/Source/BsGUISliderHandle.cpp
  9. 2 5
      Source/MBansheeEditor/GUI/GUIFloatField.cs
  10. 3 6
      Source/MBansheeEditor/GUI/GUIIntField.cs
  11. 1 0
      Source/MBansheeEditor/MBansheeEditor.csproj
  12. 1 1
      Source/MBansheeEditor/Windows/Inspector/InspectableArray.cs
  13. 2 2
      Source/MBansheeEditor/Windows/Inspector/InspectableDictionary.cs
  14. 3 4
      Source/MBansheeEditor/Windows/Inspector/InspectableField.cs
  15. 7 4
      Source/MBansheeEditor/Windows/Inspector/InspectableFloat.cs
  16. 7 5
      Source/MBansheeEditor/Windows/Inspector/InspectableInt.cs
  17. 2 6
      Source/MBansheeEditor/Windows/Inspector/InspectableRangedField.cs
  18. 2 2
      Source/MBansheeEditor/Windows/Inspector/InspectableRangedFloat.cs
  19. 5 5
      Source/MBansheeEditor/Windows/Inspector/InspectableRangedInt.cs
  20. 4 4
      Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldRangeStyle.cs
  21. 2 2
      Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldStepStyle.cs
  22. 6 37
      Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldStyle.cs
  23. 43 0
      Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldStyleInfo.cs
  24. 1 1
      Source/MBansheeEngine/Serialization/Range.cs
  25. 27 13
      Source/MBansheeEngine/Serialization/SerializableField.cs
  26. 2 2
      Source/MBansheeEngine/Serialization/Step.cs
  27. 4 0
      Source/SBansheeEngine/CMakeSources.cmake
  28. 27 0
      Source/SBansheeEngine/Include/BsScriptRange.h
  29. 2 0
      Source/SBansheeEngine/Include/BsScriptSerializableField.h
  30. 23 0
      Source/SBansheeEngine/Include/BsScriptStep.h
  31. 8 6
      Source/SBansheeEngine/Source/BsManagedSerializableObjectInfo.cpp
  32. 21 0
      Source/SBansheeEngine/Source/BsScriptRange.cpp
  33. 17 0
      Source/SBansheeEngine/Source/BsScriptStep.cpp

+ 0 - 7
Source/BansheeCore/Source/Win32/BsWin32Platform.cpp

@@ -855,13 +855,6 @@ namespace BansheeEngine
 					break; 
 				default:    // displayable character 
 					{
-						UINT8 scanCode = (lParam >> 16) & 0xFF;
-
-						BYTE keyState[256];
-						HKL layout = GetKeyboardLayout(0);
-						if(GetKeyboardState(keyState) == 0)
-							return 0;
-
 						UINT32 finalChar = (UINT32)wParam;
 
 						if(!onCharInput.empty())

+ 1 - 1
Source/BansheeEditor/Include/BsGUIFloatField.h

@@ -30,7 +30,7 @@ namespace BansheeEngine
 		/**	Returns the value of the input field. */
 		float getValue() const { return mValue; }
 
-		/**	Sets a new value in the input field. */
+		/**	Sets a new value in the input field, it returns the clamped value according to range and step. */
 		float setValue(float value);
 
 		/**

+ 1 - 1
Source/BansheeEditor/Include/BsGUIIntField.h

@@ -30,7 +30,7 @@ namespace BansheeEngine
 		/**	Returns the value of the input field. */
 		INT32 getValue() const { return mValue; }
 
-		/**	Sets a new value in the input field. */
+		/**	Sets a new value in the input field, it returns the clamped value according to range and step. */
 		INT32 setValue(INT32 value);
 
 		/**

+ 2 - 2
Source/BansheeEditor/Include/BsGUISliderField.h

@@ -36,7 +36,7 @@ namespace BansheeEngine
 		/** Gets the minimum percentual variation of the handle position */
 		float getStep() const;
 
-		/**	Sets a new value in the input field/slider. */
+		/**	Sets a new value in the input field/slider, it returns the clamped value according to range and step. */
 		float setValue(float value);
 
 		/**
@@ -80,7 +80,7 @@ namespace BansheeEngine
 		void inputBoxValueChanged(bool confirmed = true);
 
 		/**	Triggered when the input box value is changing. */
-		void inputBoxValueChanging(const WString&);
+		void inputBoxValueChanging(const WString& newValue);
 
 		/**	Triggered when the slider is moved. */
 		void sliderChanged(float newValue);

+ 2 - 3
Source/BansheeEditor/Source/BsGUIFloatField.cpp

@@ -136,9 +136,9 @@ namespace BansheeEngine
 
 	float GUIFloatField::setValue(float value)
 	{
-		mValue = Math::clamp(value, mMinValue, mMaxValue);
 		if (mStep != 0.0f)
-			mValue = mValue - fmod(mValue, mStep);
+			value = value - fmod(value, mStep);
+		mValue = Math::clamp(value, mMinValue, mMaxValue);
 		// Only update with new value if it actually changed, otherwise
 		// problems can occur when user types in "0." and the field
 		// updates back to "0" effectively making "." unusable
@@ -222,7 +222,6 @@ namespace BansheeEngine
 		{
 			UndoRedo::instance().popGroup("InputBox");
 			valueChanged(parseFloat(mInputBox->getText()));
-			onConfirm();
 			mHasInputFocus = false;
 		}
 	}

+ 1 - 1
Source/BansheeEditor/Source/BsGUIIntField.cpp

@@ -162,9 +162,9 @@ namespace BansheeEngine
 
 	INT32 GUIIntField::setValue(INT32 value)
 	{
-		mValue = Math::clamp(value, mMinValue, mMaxValue);
 		if (mStep != 0)
 			mValue = mValue - fmod(mValue, mStep);
+		mValue = Math::clamp(value, mMinValue, mMaxValue);
 		// Only update with new value if it actually changed, otherwise
 		// problems can occur when user types in "0." and the field
 		// updates back to "0" effectively making "." unusable

+ 1 - 2
Source/BansheeEditor/Source/BsGUISliderField.cpp

@@ -24,7 +24,7 @@ namespace BansheeEngine
 		mInputBox->setFilter(&GUISliderField::floatFilter);
 
 		mInputBox->onValueChanged.connect(std::bind((void(GUISliderField::*)(const WString&))&GUISliderField::inputBoxValueChanging, this, _1));
-		mInputBox->onConfirm.connect(std::bind((void(GUISliderField::*)(void))&GUISliderField::inputBoxValueChanged, this));
+		mInputBox->onConfirm.connect(std::bind(&GUISliderField::inputBoxValueChanged, this, true));
 		mInputBox->onFocusChanged.connect(std::bind(&GUISliderField::inputBoxFocusChanged, this, _1));
 
 		mLayout->addElement(mSlider);
@@ -160,7 +160,6 @@ namespace BansheeEngine
 
 	void GUISliderField::sliderChanged(float newValue)
 	{
-		//float old = mSlider->getValue();
 		_setValue(newValue, true);
 	}
 

+ 10 - 8
Source/BansheeEngine/Source/BsGUISliderHandle.cpp

@@ -173,13 +173,13 @@ namespace BansheeEngine
 
 	bool GUISliderHandle::_mouseEvent(const GUIMouseEvent& ev)
 	{
-		if(ev.getType() == GUIMouseEventType::MouseMove) //Mouse moves
+		if(ev.getType() == GUIMouseEventType::MouseMove)
 		{
 			if (!_isDisabled())
 			{
-				if (mMouseOverHandle) //It was on the handle
+				if (mMouseOverHandle)
 				{
-					if (!isOnHandle(ev.getPosition())) //It isn't anymore
+					if (!isOnHandle(ev.getPosition()))
 					{
 						mMouseOverHandle = false;
 
@@ -189,9 +189,9 @@ namespace BansheeEngine
 						return true;
 					}
 				}
-				else //It wasn't on the handle
+				else
 				{
-					if (isOnHandle(ev.getPosition())) //It is now
+					if (isOnHandle(ev.getPosition()))
 					{
 						mMouseOverHandle = true;
 
@@ -204,14 +204,14 @@ namespace BansheeEngine
 			}
 		}
 
-		if(ev.getType() == GUIMouseEventType::MouseDown && (mMouseOverHandle || mJumpOnClick)) //Mouse button is down, and the handle is being dragged or it is supposed to jump
+		if(ev.getType() == GUIMouseEventType::MouseDown && (mMouseOverHandle || mJumpOnClick))
 		{
 			if (!_isDisabled())
 			{
 				mState = State::Active;
 				_markLayoutAsDirty();
 
-				if (mJumpOnClick) //If it is supposed to jump
+				if (mJumpOnClick)
 				{
 					float handlePosPx = 0.0f;
 
@@ -288,7 +288,9 @@ namespace BansheeEngine
 					mState = State::Hover;
 				else
 					mState = State::Normal;
-				if (!mHandleDragged) {
+
+				if (!mHandleDragged) 
+				{
 					// If we clicked above or below the scroll handle, scroll by one page
 					INT32 handlePosPx = getHandlePosPx();
 					if (!mJumpOnClick)

+ 2 - 5
Source/MBansheeEditor/GUI/GUIFloatField.cs

@@ -41,14 +41,11 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Minimum change of the field
+        /// Minimum change of the field.
         /// </summary>
         public float Step
         {
-            get
-            {
-                return Internal_GetStep(mCachedPtr);
-            }
+            get { return Internal_GetStep(mCachedPtr); }
 
             set { Internal_SetStep(mCachedPtr, value); }
         }

+ 3 - 6
Source/MBansheeEditor/GUI/GUIIntField.cs

@@ -41,16 +41,13 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Minimum change of the field
+        /// Minimum change of the field.
         /// </summary>
         public int Step
         {
-            get
-            {
-                return Internal_GetStep(mCachedPtr);
-            }
+            get { return Internal_GetStep(mCachedPtr); }
 
-            set { Internal_SetStep(mCachedPtr, value);}
+            set { Internal_SetStep(mCachedPtr, value); }
         }
 
         /// <summary>

+ 1 - 0
Source/MBansheeEditor/MBansheeEditor.csproj

@@ -84,6 +84,7 @@
     <Compile Include="Windows\Inspector\InspectableRangedField.cs" />
     <Compile Include="Windows\Inspector\InspectableRangedFloat.cs" />
     <Compile Include="Windows\Inspector\InspectableRangedInt.cs" />
+    <Compile Include="Windows\Inspector\Style\InspectableFieldStyleInfo.cs" />
     <Compile Include="Windows\LogWindow.cs" />
     <Compile Include="Window\DefaultSize.cs" />
     <Compile Include="Windows\DialogBox.cs" />

+ 1 - 1
Source/MBansheeEditor/Windows/Inspector/InspectableArray.cs

@@ -318,7 +318,7 @@ namespace BansheeEditor
 
                 string entryPath = arrayParent.Path + "[" + SeqIndex + "]";
                 field = CreateInspectable(arrayParent.Inspector, SeqIndex + ".", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
+                    new InspectableFieldLayout(layout), property);
 
                 return field.GetTitleLayout();
             }

+ 2 - 2
Source/MBansheeEditor/Windows/Inspector/InspectableDictionary.cs

@@ -377,7 +377,7 @@ namespace BansheeEditor
 
                 string entryPath = dictParent.Path + "Key[" + RowIdx + "]";
                 fieldKey = CreateInspectable(dictParent.Inspector, "Key", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
+                    new InspectableFieldLayout(layout), property);
 
                 return fieldKey.GetTitleLayout();
             }
@@ -390,7 +390,7 @@ namespace BansheeEditor
 
                 string entryPath = dictParent.Path + "Value[" + RowIdx + "]";
                 fieldValue = CreateInspectable(dictParent.Inspector, "Value", entryPath, 0, Depth + 1,
-                    new InspectableFieldLayout(layout), property, new InspectableFieldStyleInfo());
+                    new InspectableFieldLayout(layout), property);
             }
 
             /// <inheritdoc/>

+ 3 - 4
Source/MBansheeEditor/Windows/Inspector/InspectableField.cs

@@ -1,7 +1,6 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 using System;
-using System.Linq;
 using BansheeEngine;
  
 namespace BansheeEditor
@@ -134,7 +133,7 @@ namespace BansheeEditor
         /// <returns>Inspectable field implementation that can be used for displaying the GUI for a serializable property
         ///          of the provided type.</returns>
         public static InspectableField CreateInspectable(Inspector parent, string title, string path, int layoutIndex, 
-            int depth, InspectableFieldLayout layout, SerializableProperty property, InspectableFieldStyleInfo style)
+            int depth, InspectableFieldLayout layout, SerializableProperty property, InspectableFieldStyleInfo style = null)
         {
             InspectableField field = null;
 
@@ -148,7 +147,7 @@ namespace BansheeEditor
                 switch (property.Type)
                 {
                     case SerializableProperty.FieldType.Int:
-                        if (style.RangeStyle == null || !style.RangeStyle.Slider)
+                        if (style?.RangeStyle == null || !style.RangeStyle.Slider)
                         {
                             field = new InspectableInt(parent, title, path, depth, layout, property, style);
                         }
@@ -158,7 +157,7 @@ namespace BansheeEditor
                         }
                         break;
                     case SerializableProperty.FieldType.Float:
-                        if (style.RangeStyle == null || !style.RangeStyle.Slider)
+                        if (style?.RangeStyle == null || !style.RangeStyle.Slider)
                         {
                             field = new InspectableFloat(parent, title, path, depth, layout, property, style);
                         }

+ 7 - 4
Source/MBansheeEditor/Windows/Inspector/InspectableFloat.cs

@@ -41,10 +41,13 @@ namespace BansheeEditor
             if (property != null)
             {
                 guiFloatField = new GUIFloatField(new GUIContent(title));
-                if (style.StepStyle != null && style.StepStyle.Step != 0)
-                    guiFloatField.Step = style.StepStyle.Step;
-                if (style.RangeStyle != null)
-                    guiFloatField.SetRange(style.RangeStyle.Min, style.RangeStyle.Max);
+                if (style != null)
+                {
+                    if (style.StepStyle != null && style.StepStyle.Step != 0)
+                        guiFloatField.Step = style.StepStyle.Step;
+                    if (style.RangeStyle != null)
+                        guiFloatField.SetRange(style.RangeStyle.Min, style.RangeStyle.Max);
+                }
                 guiFloatField.OnChanged += OnFieldValueChanged;
                 guiFloatField.OnConfirmed += OnFieldValueConfirm;
                 guiFloatField.OnFocusLost += OnFieldValueConfirm;

+ 7 - 5
Source/MBansheeEditor/Windows/Inspector/InspectableInt.cs

@@ -42,11 +42,13 @@ namespace BansheeEditor
             if (property != null)
             {
                 guiIntField = new GUIIntField(new GUIContent(title));
-                if (style.StepStyle != null && style.StepStyle.Step != 0)
-                    guiIntField.Step = (int)style.StepStyle.Step;
-
-                if (style.RangeStyle != null)
-                    guiIntField.SetRange((int)style.RangeStyle.Min, (int)style.RangeStyle.Max);
+                if (style != null)
+                {
+                    if (style.StepStyle != null && style.StepStyle.Step != 0)
+                        guiIntField.Step = (int) style.StepStyle.Step;
+                    if (style.RangeStyle != null)
+                        guiIntField.SetRange((int) style.RangeStyle.Min, (int) style.RangeStyle.Max);
+                }
                 guiIntField.OnChanged += OnFieldValueChanged;
                 guiIntField.OnConfirmed += OnFieldValueConfirm;
                 guiIntField.OnFocusLost += OnFieldValueConfirm;

+ 2 - 6
Source/MBansheeEditor/Windows/Inspector/InspectableRangedField.cs

@@ -1,6 +1,5 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-using System;
 using BansheeEngine;
 
 namespace BansheeEditor
@@ -10,16 +9,13 @@ namespace BansheeEditor
      */
 
     /// <summary>
-    /// Inspectable field displays GUI elements for a single <see cref="SerializableProperty"/>. This is a base class that
-    /// should be specialized for all supported types contained by <see cref="SerializableProperty"/>. Inspectable fields
-    /// can and should be created recursively - normally complex types like objects and arrays will contain fields of their 
-    /// own, while primitive types like integer or boolean will consist of only a GUI element.
+    /// IsnpectableRangedField is a <see cref="InspectableField"/> that has a Range attribute and must be rendered as a slider.
     /// </summary>
     public abstract class InspectableRangedField : InspectableField
     {
         protected InspectableFieldStyleInfo style;
         /// <summary>
-        /// Creates a new inspectable field GUI for the specified property.
+        /// Creates a new inspectable ranged field GUI for the specified property.
         /// </summary>
         /// <param name="parent">Parent Inspector this field belongs to.</param>
         /// <param name="title">Name of the property, or some other value to set as the title.</param>

+ 2 - 2
Source/MBansheeEditor/Windows/Inspector/InspectableRangedFloat.cs

@@ -26,7 +26,7 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
-        /// <param name="style">Contains information about the field style</param>
+        /// <param name="style">Contains information about the field style.</param>
         public InspectableRangedFloat(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout,
             SerializableProperty property, InspectableFieldStyleInfo style)
             : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property, style)
@@ -40,7 +40,7 @@ namespace BansheeEditor
             if (property != null)
             {
                 guiFloatField = new GUISliderField(style.RangeStyle.Min, style.RangeStyle.Max, new GUIContent(title));
-                if (style.StepStyle != null && style.StepStyle.Step != 0)
+                if (style != null && style.StepStyle != null && style.StepStyle.Step != 0)
                     guiFloatField.Step = style.StepStyle.Step;
                 guiFloatField.OnChanged += OnFieldValueChanged;
                 guiFloatField.OnFocusLost += OnFieldValueConfirm;

+ 5 - 5
Source/MBansheeEditor/Windows/Inspector/InspectableRangedInt.cs

@@ -9,7 +9,7 @@ namespace BansheeEditor
      */
 
     /// <summary>
-    /// Displays GUI for a serializable property containing a floating point value.
+    /// Displays GUI for a serializable property containing an integer value with a range.
     /// </summary>
     public class InspectableRangedInt : InspectableRangedField
     {
@@ -26,7 +26,7 @@ namespace BansheeEditor
         ///                     contain other fields, in which case you should increase this value by one.</param>
         /// <param name="layout">Parent layout that all the field elements will be added to.</param>
         /// <param name="property">Serializable property referencing the array whose contents to display.</param>
-        /// <param name="style">Information about the range of the field</param>
+        /// <param name="style">Information about the range of the field.</param>
         public InspectableRangedInt(Inspector parent, string title, string path, int depth, InspectableFieldLayout layout,
             SerializableProperty property, InspectableFieldStyleInfo style)
             : base(parent, title, path, SerializableProperty.FieldType.Float, depth, layout, property, style)
@@ -40,7 +40,7 @@ namespace BansheeEditor
             if (property != null)
             {
                 guiIntField = new GUISliderField(style.RangeStyle.Min, style.RangeStyle.Max, new GUIContent(title));
-                if (style.StepStyle != null && style.StepStyle.Step != 0)
+                if (style != null && style.StepStyle != null && style.StepStyle.Step != 0)
                     guiIntField.Step = style.StepStyle.Step;
                 guiIntField.OnChanged += OnFieldValueChanged;
                 guiIntField.OnFocusLost += OnFieldValueConfirm;
@@ -63,7 +63,7 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Triggered when the user inputs a new floating point value.
+        /// Triggered when the user inputs a new integer value.
         /// </summary>
         /// <param name="newValue">New value of the float field.</param>
         private void OnFieldValueChanged(float newValue)
@@ -73,7 +73,7 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Triggered when the user confirms input in the float field.
+        /// Triggered when the user confirms input in the int field.
         /// </summary>
         private void OnFieldValueConfirm()
         {

+ 4 - 4
Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldRangeStyle.cs

@@ -4,7 +4,7 @@
 namespace BansheeEditor
 {
     /// <summary>
-    /// Contains info about the range of values a field can store
+    /// Contains info about the range of values a field can store.
     /// </summary>
     public sealed class InspectableFieldRangeStyle : InspectableFieldStyle
     {
@@ -16,17 +16,17 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// The maximum value the field can be assigned
+        /// The maximum value the field can be assigned.
         /// </summary>
         public float Max { get; set; }
 
         /// <summary>
-        /// The minimum value the field can be assigned
+        /// The minimum value the field can be assigned.
         /// </summary>
         public float Min { get; set; }
 
         /// <summary>
-        /// Whether the field is rendered as a slider
+        /// Whether the field is rendered as a slider.
         /// </summary>
         public bool Slider { get; set; }
     }

+ 2 - 2
Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldStepStyle.cs

@@ -4,7 +4,7 @@
 namespace BansheeEditor
 {
     /// <summary>
-    /// Contains information about the minimum change allowed to a field value
+    /// Contains information about the minimum change allowed to a field value.
     /// </summary>
     public sealed class InspectableFieldStepStyle : InspectableFieldStyle
     {
@@ -15,7 +15,7 @@ namespace BansheeEditor
         }
 
         /// <summary>
-        /// Minimum change of the field. Every change will be rounded to a multiple of this value
+        /// Minimum change of the field. Every change will be rounded to a multiple of this value.
         /// </summary>
         public float Step { get; set; }
     }

+ 6 - 37
Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldStyle.cs

@@ -1,57 +1,26 @@
 //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 
-using System;
-using System.Collections.Generic;
 using BansheeEngine;
 
 namespace BansheeEditor
 {
     /// <summary>
-    /// Contains boolean information about a field style
-    /// </summary>
-    public enum InstectableFieldStyleFlags
-    {
-        None = 0,
-        UseSlider = 1,   
-    }
-
-    /// <summary>
-    /// Contains all the information about a field style
-    /// </summary>
-    public struct InspectableFieldStyleInfo
-    {
-        /// <summary>
-        /// Information about the field range
-        /// </summary>
-        public InspectableFieldRangeStyle RangeStyle;
-
-        /// <summary>
-        /// Information about the field stepping
-        /// </summary>
-        public InspectableFieldStepStyle StepStyle;
-
-        /// <summary>
-        /// Boolean information about the field
-        /// </summary>
-        public InstectableFieldStyleFlags StyleFlags;
-    }
-    /// <summary>
-    /// Contains style information about inspectable items
+    /// Contains style information about inspectable items.
     /// </summary>
     public abstract class InspectableFieldStyle
     {
         /// <summary>
-        /// Creates all the relevant style information for a SerializableField
+        /// Creates all the relevant style information for a SerializableField.
         /// </summary>
-        /// <param name="field">A SerializableField</param>
-        /// <returns>Style information</returns>
+        /// <param name="field">A SerializableField.</param>
+        /// <returns>Style information.</returns>
         public static InspectableFieldStyleInfo Create(SerializableField field)
         {
             var styleInfo = new InspectableFieldStyleInfo();
 
-            styleInfo.RangeStyle = field.Ranged? new InspectableFieldRangeStyle(field.RangeMinimum, field.RangeMaximum, field.IsSlider) : null;
-            styleInfo.StepStyle = field.Stepped? new InspectableFieldStepStyle(field.Step) : null;
+            styleInfo.RangeStyle = field.IsRanged? new InspectableFieldRangeStyle(field.RangeMinimum, field.RangeMaximum, field.IsSlider) : null;
+            styleInfo.StepStyle = field.IsStepped? new InspectableFieldStepStyle(field.Step) : null;
             return styleInfo;
         }
     }

+ 43 - 0
Source/MBansheeEditor/Windows/Inspector/Style/InspectableFieldStyleInfo.cs

@@ -0,0 +1,43 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+
+namespace BansheeEditor
+{
+    /// <summary>
+    /// Contains boolean information about a field style.
+    /// </summary>
+    public enum InstectableFieldStyleFlags
+    {
+        None = 0,
+        UseSlider = 1,
+    }
+
+    /// <summary>
+    /// Contains all the information about a field style.
+    /// </summary>
+    public class InspectableFieldStyleInfo
+    {
+        /// <summary>
+        /// Information about the field range.
+        /// </summary>
+        public InspectableFieldRangeStyle RangeStyle;
+
+        /// <summary>
+        /// Information about the field stepping.
+        /// </summary>
+        public InspectableFieldStepStyle StepStyle;
+
+        /// <summary>
+        /// Boolean information about the field.
+        /// </summary>
+        public InstectableFieldStyleFlags StyleFlags;
+
+        /// <summary>
+        /// Creates an empty set of information about a field style.
+        /// </summary>
+        public InspectableFieldStyleInfo()
+        {
+            
+        }
+    }
+}

+ 1 - 1
Source/MBansheeEngine/Serialization/Range.cs

@@ -19,7 +19,7 @@ namespace BansheeEngine
         /// </summary>
         /// <param name="min">Minimum boundary of the range to clamp the field value to.</param>
         /// <param name="max">Maximum boundary of the range to clamp the field value to.</param>
-        /// <param name="slider">Whether the field should be rendered as a slider</param>
+        /// <param name="slider">Whether the field should be rendered as a slider.</param>
         public Range(float min, float max, bool slider = true)
         {
             this.min = min;

+ 27 - 13
Source/MBansheeEngine/Serialization/SerializableField.cs

@@ -9,6 +9,17 @@ namespace BansheeEngine
      *  @{
      */
 
+    /// <summary>
+    /// Flags as defined in native code in BsManagedSerializableObjectInfo.h
+    /// </summary>
+    enum SerializableFieldAttributes : byte
+    {
+        Serializable = 0x01,
+        Inspectable = 0x02,
+        Ranged = 0x04,
+        Stepped = 0x08
+    }
+
     /// <summary>
     /// Allows you to access meta-data about field in an object. Similar to Reflection but simpler and faster.
     /// </summary>
@@ -63,38 +74,41 @@ namespace BansheeEngine
         /// <summary>
         /// Returns true if the field accepts a defined range.
         /// </summary>
-        public bool Ranged
+        public bool IsRanged
         {
-            get { return (flags & 0x04) != 0; }
+            get { return (flags & (byte)SerializableFieldAttributes.Ranged) != 0; }
         }
 
         /// <summary>
-        /// Returns the upper bound of the range
+        /// Returns the upper bound of the range.
         /// </summary>
         public float RangeMaximum
         {
-            get { return Ranged? Internal_GetRangeMaximum(mCachedPtr) : 0; }
+            get { return IsRanged? Internal_GetRangeMaximum(mCachedPtr) : 0; }
         }
 
         /// <summary>
-        /// Returns the lower bound of the range
+        /// Returns the lower bound of the range.
         /// </summary>
         public float RangeMinimum
         {
-            get { return Ranged? Internal_GetRangeMinimum(mCachedPtr) : 0; }
+            get { return IsRanged? Internal_GetRangeMinimum(mCachedPtr) : 0; }
         }
 
         /// <summary>
-        /// Whether the field is rendered as a slider
+        /// Whether the field is rendered as a slider.
         /// </summary>
         public bool IsSlider
         {
-            get { return (Ranged && Internal_RenderAsSlider(mCachedPtr)); }
+            get { return (IsRanged && Internal_RenderAsSlider(mCachedPtr)); }
         }
 
-        public bool Stepped
+        /// <summary>
+        /// Whether the field has an associated step value.
+        /// </summary>
+        public bool IsStepped
         {
-            get { return (flags & 0x04) != 0; }
+            get { return (flags & (byte)SerializableFieldAttributes.Stepped) != 0; }
         }
 
         /// <summary>
@@ -102,7 +116,7 @@ namespace BansheeEngine
         /// </summary>
         public float Step
         {
-            get { return Internal_GetStep(mCachedPtr); }
+            get { return IsStepped? Internal_GetStep(mCachedPtr) : 0; }
         }
 
         /// <summary>
@@ -110,7 +124,7 @@ namespace BansheeEngine
         /// </summary>
         public bool Inspectable
         {
-            get { return (flags & 0x02) != 0; } // Flags as defined in native code in BsManagedSerializableObjectInfo.h
+            get { return (flags & (byte)SerializableFieldAttributes.Inspectable) != 0; }
         }
 
         /// <summary>
@@ -118,7 +132,7 @@ namespace BansheeEngine
         /// </summary>
         public bool Serializable
         {
-            get { return (flags & 0x01) != 0; } // Flags as defined in native code in BsManagedSerializableObjectInfo.h
+            get { return (flags & (byte)SerializableFieldAttributes.Serializable) != 0; }
         }
 
         /// <summary>

+ 2 - 2
Source/MBansheeEngine/Serialization/Step.cs

@@ -15,9 +15,9 @@ namespace BansheeEngine
     public sealed class Step : Attribute
     {
         /// <summary>
-        /// Creates a new Step attribute
+        /// Creates a new Step attribute.
         /// </summary>
-        /// <param name="step">Minimum change of the field. Every change will be rounded to a multiple of this value</param>
+        /// <param name="step">Minimum change of the field. Every change will be rounded to a multiple of this value.</param>
         public Step(float step)
         {
             this.step = step;

+ 4 - 0
Source/SBansheeEngine/CMakeSources.cmake

@@ -15,6 +15,8 @@ set(BS_SBANSHEEENGINE_INC_NOFILTER
 )
 
 set(BS_SBANSHEEENGINE_SRC_WRAPPERS_GUI
+	"Source/BsScriptRange.cpp"
+	"Source/BsScriptStep.cpp"
 	"Source/BsScriptGUIButton.cpp"
 	"Source/BsScriptGUIContent.cpp"
 	"Source/BsScriptGUIElementStateStyle.cpp"
@@ -144,6 +146,8 @@ set(BS_SBANSHEEENGINE_INC_WRAPPERS
 )
 
 set(BS_SBANSHEEENGINE_INC_WRAPPERS_GUI
+	"Include/BsScriptRange.h"
+	"Include/BsScriptStep.h"
 	"Include/BsScriptGUIButton.h"
 	"Include/BsScriptGUIContent.h"
 	"Include/BsScriptGUIElementStateStyle.h"

+ 27 - 0
Source/SBansheeEngine/Include/BsScriptRange.h

@@ -0,0 +1,27 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+
+namespace BansheeEngine
+{
+	/**	Interop class between C++ & CLR for Range attribute. */
+	class BS_SCR_BE_EXPORT ScriptRange : public ScriptObject <ScriptRange>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Range")
+
+		static MonoField* getMinRangeField() { return minRangeField; }
+		static MonoField* getMaxRangeField() { return maxRangeField; }
+		static MonoField* getSliderField() { return sliderField; }
+
+	private:
+		ScriptRange(MonoObject* instance);
+
+		static MonoField* minRangeField;
+		static MonoField* maxRangeField;
+		static MonoField* sliderField;
+	};
+}

+ 2 - 0
Source/SBansheeEngine/Include/BsScriptSerializableField.h

@@ -33,6 +33,8 @@ namespace BansheeEngine
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
+		static MonoField* rangeAttribute;
+		static MonoField* stepAttribute;
 		static MonoObject* internal_createProperty(ScriptSerializableField* nativeInstance);
 		static MonoObject* internal_getValue(ScriptSerializableField* nativeInstance, MonoObject* instance);
 		static void internal_setValue(ScriptSerializableField* nativeInstance, MonoObject* instance, MonoObject* value);

+ 23 - 0
Source/SBansheeEngine/Include/BsScriptStep.h

@@ -0,0 +1,23 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsScriptEnginePrerequisites.h"
+#include "BsScriptObject.h"
+
+namespace BansheeEngine
+{
+	/**	Interop class between C++ & CLR for Step attribute. */
+	class BS_SCR_BE_EXPORT ScriptStep : public ScriptObject <ScriptStep>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "Step")
+
+		static MonoField* getStepField() { return stepField; }
+
+	private:
+		ScriptStep(MonoObject* instance);
+
+		static MonoField* stepField;
+	};
+}

+ 8 - 6
Source/SBansheeEngine/Source/BsManagedSerializableObjectInfo.cpp

@@ -2,6 +2,7 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsManagedSerializableObjectInfo.h"
 #include "BsManagedSerializableObjectInfoRTTI.h"
+#include "BsScriptRange.h"
 #include "BsMonoUtil.h"
 #include "BsMonoClass.h"
 #include "BsMonoManager.h"
@@ -26,6 +27,7 @@
 #include "BsScriptAnimationClip.h"
 #include "BsScriptPrefab.h"
 #include "BsScriptManagedResource.h"
+#include <BsScriptStep.h>
 
 namespace BansheeEngine
 {
@@ -105,7 +107,7 @@ namespace BansheeEngine
 			if (range != nullptr)
 			{
 				float min = 0;
-				range->getField("min")->getValue(mMonoField->getAttribute(range), &min);
+				ScriptRange::getMinRangeField()->getValue(mMonoField->getAttribute(range), &min);
 				return min;
 			}
 		}
@@ -121,7 +123,7 @@ namespace BansheeEngine
 			if (range != nullptr)
 			{
 				float max = 0;
-				range->getField("max")->getValue(mMonoField->getAttribute(range), &max);
+				ScriptRange::getMaxRangeField()->getValue(mMonoField->getAttribute(range), &max);
 				return max;
 			}
 		}
@@ -136,12 +138,12 @@ namespace BansheeEngine
 			if (range != nullptr)
 			{
 				bool slider = false;
-				range->getField("slider")->getValue(mMonoField->getAttribute(range), &slider);
+				ScriptRange::getSliderField()->getValue(mMonoField->getAttribute(range), &slider);
 				return slider;
 			}
 		}
 		return false;
-	}
+	}
 
 
 	float ManagedSerializableFieldInfo::getStep() const
@@ -153,7 +155,7 @@ namespace BansheeEngine
 			if (step != nullptr)
 			{
 				float value = 0;
-				step->getField("step")->getValue(mMonoField->getAttribute(step), &value);
+				ScriptStep::getStepField()->getValue(mMonoField->getAttribute(step), &value);
 				return value;
 			}
 		}
@@ -495,4 +497,4 @@ namespace BansheeEngine
 	{
 		return ManagedSerializableTypeInfoDictionary::getRTTIStatic();
 	}
-}
+}

+ 21 - 0
Source/SBansheeEngine/Source/BsScriptRange.cpp

@@ -0,0 +1,21 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+
+#include "BsScriptRange.h"
+#include "BsScriptEnginePrerequisites.h"
+
+namespace BansheeEngine
+{
+	MonoField* ScriptRange::sliderField = nullptr;
+	MonoField* ScriptRange::minRangeField = nullptr;
+	MonoField* ScriptRange::maxRangeField = nullptr;
+
+	ScriptRange::ScriptRange(MonoObject* instance) : ScriptObject(instance)
+	{ }
+	void ScriptRange::initRuntimeData()
+	{
+		minRangeField = metaData.scriptClass->getField("min");
+		maxRangeField = metaData.scriptClass->getField("max");
+		sliderField = metaData.scriptClass->getField("slider");
+	}
+}

+ 17 - 0
Source/SBansheeEngine/Source/BsScriptStep.cpp

@@ -0,0 +1,17 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+
+#include "BsScriptEnginePrerequisites.h"
+#include <BsScriptStep.h>
+
+namespace BansheeEngine
+{
+	MonoField* ScriptStep::stepField = nullptr;
+
+	ScriptStep::ScriptStep(MonoObject* instance) : ScriptObject(instance)
+	{ }
+	void ScriptStep::initRuntimeData()
+	{
+		stepField = metaData.scriptClass->getField("step");
+	}
+}