I'm making this post so it's public and maybe it'll help the RainyRizzle team improve AnyPortrait if they can see how their tool is being used!
Be warned though, my code isn't commented, so hopefully the method name is descriptive enough.
APHelper is a helper script that I use to help myself quickly get values from control parameters and make useful calculations that aren't public methods in AnyPortrait. I also don't differentiate between Int, Float, and Vector2 Control Parameter types, because it's incredibly tedious code-wise to worry about the type when you just want to simply get the value.
Separating the functionality into X and Y instead of Int, Float, and Vector2 made it simpler, for me personally, to implement the following script:
The top portion of the code isn't important to the discussion. Please ignore the #region named MeshInteract. Within the #region ControlParam, thanks to APHelper, I was able to just boil down to only four simple methods relevant to AnyPortrait's Control Parameters.
I only need to hook up ParamController.cs to a GameObject, give it the relevant ApPortrait.cs, and Control Parameter name. After that you can just call that ParamController.cs and call Up, Down, Left, Right without having to worry about value types and such.
Final thoughts:
I don't know if AnyPortrait's Control Parameters only use one primitive type underneath the hood, but if it does have three different primitive types then it is overly complex. I'm ignorant of the backend AnyPortrait but I do think that having a unified type will not only be easier on the user but also be easier for the developers at RainyRizzle.
It's just my opinion and if anyone has any feedback for a better way I could've handled my functions, please do tell, I'm very interested in hearing it.
Hi, Son Huynh.
Thank you for your nice post!
Our team has checked the scripts you have attached, and we think there may be other projects where your ideas may be applied.
We agree that accessing and controlling the Control Parameter without considering the type can increase the working efficiency of programming.
Your idea of using SnapSize to control the movement of values in floating types was also good.
Prior to the explanation below, we think your idea is very good, and if necessary, we can add "functions that control the Control Parameter without asking the type" like this idea.
We would like to explain the reason why the types of control parameters of AnyPortrait are separated from the aspect of the internal system as follows.
It's hard for us to explain all about AnyPortrait's "Control Parameter" system, but we'll briefly explain why types are separated.
The most used logic in animation tools is "Interpolation".
The calculation process of calculating the value between a key and a key is also the basis of animation, and also the basis of complex systems.
In the same way, the character is controlled by calculating the values between the recorded keys of the control parameters.
In this system, the reason of being divided into Integer, Float, and Vector2 types is that there are differences in interpolation, in addition to simply having the value of the key with that type.
Basic Interpolation calculation is applied to Float type.
The Integer type goes through a slightly more complex Interpolation step in animation.
Animation curves of type Integer are also set differently from Float.
The Vector2 type has a completely different interpolation process.
When adding a key to a Vector2 type Control Parameter, users do not have to add all the keys to the Min-Max of each axis.
This is a nice and unique feature of AnyPortrait, which creates a kind of "ghost key" that allows users to freely add keys to any location, making interpolation look natural!
Of course, for this feature, interpolation for the Vector2 type uses fairly complex logic.
Regardless of this structure, in other words, users don't need to know this, so writing a script like your Helper is a very good way, and we recommend this implementation.
This detailed and in-depth suggestion is very helpful for us to improve AnyPortrait.
We are deeply grateful for your ideas.
Thank you!