+3
Answered

DOTween and Lambda Getters and Setters

JasonJonesLASM 3 years ago updated 3 years ago 10

I've been trying to implement DOTween into Bolt without creating a wrapper function in C#. Unfortunately it calls for a getter/setter on almost all tweens and uses their own implementation called DOGetter<> and DOSetter<>, neither which will convert without the existing syntax of a lambda in it. Something I'm missing to do this? Tried with a float, and says can't convert from System. Single to 1[Systems. Single]. Hoping I don't need to wrap all types in my own function. 

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

Answer

+3
Answer
Answered

Instead of providing a graph syntax for delegates, which as I mentioned is a lot of work, this will be handled in the deep tweening integration I have planned. With this system, every property or field that can be both get and set will be tweenable. For example, if there is a Get Position and Set Position units available, there will also be a Tween Position unit right below. This will also work for custom properties like player health without any additional work required on the user's end.

I can not implement this code

ShortcutExtensions.DOMove(character, spawnTarget.position, 2f);
TweenSettingsExtensions.OnComplete<tweener>(ShortcutExtensions.DOMove(character, spawnTarget.position, 2f), TweenComplete);

or

transform.DOMove(character, spawnTarget.position, 2f).OnComplete(TweenComplete);

In the same boat. Been strictly working on this for the past day and a half. Tried DOVirtual, shortcuts, and regular. For now I'm seeing more progress wrapping a tween inside a function in C# with In and Out variables as floats and a Target ones. Still can't get the variable I intend to update, to update though. It is going for the amount time duration I give it. Figure I'm just missing something. Used to strictly calling an update callback too exchange values, but I'm using static functions to make my game dev a bit more modular with nodes to create different types of things. So I have no instance in the script to work with.

So my code looks  in nottorus


Should work no different, you getting a reflection error? That's what happens to me when I try to use the shortcuts.. 

And I do not see the OnComplete function

Pending Review

I'll have to look into this some more, but have you added ShortcutExtensions and TweenSettingsExtensions to your custom type options?

Do you get any error or warning before you see that reflection failure node?

(Note that I eventually want a "deep integration" with DOTween, but for now I want to get this regular approach to work as well.)

Bolt does not support lambdas or delegate "literals" unfortunately, because they're very hard to represent graphically. I have an idea of how to do it, but it'd be a major new feature that could take weeks of work.  In the mean time though, all the DO* methods should work.

Thank you, I did add them already. I get no errors except the Reflection Failure, failed to find member. Nothing  in either of those works, and is greyed out. Normal Tweens work just fine though, with the exception you can't actually use it without lambda. Here is a photo, even if it doesn't do much. 

+2

I just realized I indeed can use DO Move and such as long as it is under Transform, Rect, ect. Then that leaves me with the ability to not be able to tween things like Floats and such. Guess I will just have to wrap it up in a script for now until there is the deeper integration. If I get something working properly, I'll share it for others to use in the meantime. 

+3
Answer
Answered

Instead of providing a graph syntax for delegates, which as I mentioned is a lot of work, this will be handled in the deep tweening integration I have planned. With this system, every property or field that can be both get and set will be tweenable. For example, if there is a Get Position and Set Position units available, there will also be a Tween Position unit right below. This will also work for custom properties like player health without any additional work required on the user's end.

+2

Love that.  Sounds quick, and taking away the need to know about everything behind the hood is great. Makes it feel very streamlined, and Bolt like.