diff --git a/Source/Editor/GUI/Input/UIntValueBox.cs b/Source/Editor/GUI/Input/UIntValueBox.cs index 9f1b2c1f4..d691be116 100644 --- a/Source/Editor/GUI/Input/UIntValueBox.cs +++ b/Source/Editor/GUI/Input/UIntValueBox.cs @@ -143,6 +143,8 @@ namespace FlaxEditor.GUI.Input try { var value = ShuntingYard.Parse(Text); + if (value < 0) + value = 0; Value = (uint)value; } catch (Exception ex) diff --git a/Source/Editor/Surface/Archetypes/Constants.cs b/Source/Editor/Surface/Archetypes/Constants.cs index 63cec366b..3ae9d6a8a 100644 --- a/Source/Editor/Surface/Archetypes/Constants.cs +++ b/Source/Editor/Surface/Archetypes/Constants.cs @@ -379,7 +379,7 @@ namespace FlaxEditor.Surface.Archetypes Elements = new[] { NodeElementArchetype.Factory.Output(0, "Value", typeof(uint), 0), - NodeElementArchetype.Factory.Integer(0, 0, 0) + NodeElementArchetype.Factory.UnsignedInteger(0, 0, 0, -1, 0, int.MaxValue) } }, }; diff --git a/Source/Editor/Surface/Elements/UnsignedIntegerValue.cs b/Source/Editor/Surface/Elements/UnsignedIntegerValue.cs index 9668105f1..a1822a268 100644 --- a/Source/Editor/Surface/Elements/UnsignedIntegerValue.cs +++ b/Source/Editor/Surface/Elements/UnsignedIntegerValue.cs @@ -85,7 +85,7 @@ namespace FlaxEditor.Surface.Elements else if (value is Vector4 valueVec4) result = (uint)(arch.BoxID == 0 ? valueVec4.X : arch.BoxID == 1 ? valueVec4.Y : arch.BoxID == 2 ? valueVec4.Z : valueVec4.W); else - result = 0; + result = 0u; return result; } diff --git a/Source/Editor/Surface/NodeElementArchetype.cs b/Source/Editor/Surface/NodeElementArchetype.cs index 07ea35875..cc2f41106 100644 --- a/Source/Editor/Surface/NodeElementArchetype.cs +++ b/Source/Editor/Surface/NodeElementArchetype.cs @@ -239,6 +239,32 @@ namespace FlaxEditor.Surface }; } + /// + /// Creates new Unsigned Integer value element description. + /// + /// The x location (in node area space). + /// The y location (in node area space). + /// The index of the node variable linked as the input. Useful to make a physical connection between input box and default value for it. + /// The index of the component to edit. For vectors this can be set to modify only single component of it. Eg. for vec2 value component set to 1 will edit only Y component. Default value -1 will be used to edit whole value. + /// The minimum value range. + /// The maximum value range. + /// The archetype. + public static NodeElementArchetype UnsignedInteger(float x, float y, int valueIndex = -1, int component = -1, uint valueMin = 0, uint valueMax = 1000000) + { + return new NodeElementArchetype + { + Type = NodeElementType.UnsignedIntegerValue, + Position = new Vector2(Constants.NodeMarginX + x, Constants.NodeMarginY + Constants.NodeHeaderSize + y), + Text = null, + Single = false, + ValueIndex = valueIndex, + ValueMin = valueMin, + ValueMax = valueMax, + BoxID = -1, + ConnectionsType = ScriptType.Null + }; + } + /// /// Creates new Float value element description. /// diff --git a/Source/Editor/Surface/NodeElementType.cs b/Source/Editor/Surface/NodeElementType.cs index 48b2356dd..f104b234c 100644 --- a/Source/Editor/Surface/NodeElementType.cs +++ b/Source/Editor/Surface/NodeElementType.cs @@ -94,5 +94,10 @@ namespace FlaxEditor.Surface /// The actor picker. /// Actor = 19, + + /// + /// The unsigned integer value. + /// + UnsignedIntegerValue = 20, } } diff --git a/Source/Editor/Surface/SurfaceNode.cs b/Source/Editor/Surface/SurfaceNode.cs index cf39384ce..1989992df 100644 --- a/Source/Editor/Surface/SurfaceNode.cs +++ b/Source/Editor/Surface/SurfaceNode.cs @@ -267,6 +267,9 @@ namespace FlaxEditor.Surface case NodeElementType.Actor: element = new ActorSelect(this, arch); break; + case NodeElementType.UnsignedIntegerValue: + element = new UnsignedIntegerValue(this, arch); + break; //default: throw new NotImplementedException("Unknown node element type: " + arch.Type); } if (element != null)