Hi Everyone, I’m trying to make an Editor Scripting Utility in C++ and I was wondering if I could limit the input of the function, in this case for example I need the parameter to always be > 0:
I could use “clamp” or a simple “if” to check if the number is less than one and change it to one, but that would only affect the result and not “what the user sees”
if (NumberOfDuplicates < 1)
{
NumberOfDuplicates = 1;
}
I also noticed that the value is automatically limited to positive numbers, so in this case I’d just need to exclude the 0, but I’m curious to know how to allow negative numbers in the input:
Thanks for your answer, I’ve tried to use the meta tag for UPROPERTY (only ClampMin to be honest) but it looks like it’s getting ignored (and it makes sense, because if you have more than one integer variable the program doesn’t know which variable to limit, and that meta is not present in the “Function Metadata Specifiers” of the documentation).
Maybe there’s a way to specify meta tags for each parameter but I haven’t been able to find it!
Yeah worth a try anyway. What about rather than passing them in as method parameters you just have them as UPROPERTIES that the CallInEditor method references?
That’s an option that I considered, but I have many functions that have the same parameter name and accept different values, so that doesn’t apply very well.
I’m probably going to use a widget and limit the value from there…
There’s not a way to prevent a function from being called with a parameter that is out of bounds, clamp parameters only work on editor values for properties.
So, if you have a property setup that defines the value to call the function with, then you can clamp the min/max on the property. But you can’t clamp the function call itself.
I’ve always used int32, this is literally the first time I used “uint32” because I was following a tutorial, I thought that the “U” was just something like the prefix with “UObject”, I would have never Imagined that it meant “unsigned” .
Thank you so much again, it’s kinda strange to discover this after a year and a half of using Unreal