我正在开发一个可以在运行时修改动画的小程序(例如,当您运行得更快时,动画不仅播放速度更快,而且移动幅度更大)。所以我需要获取现有动画,更改其值,然后将其发回。
我发现有趣的是我可以为动画设置一条新曲线,但我无法访问我已经拥有的曲线。所以我要么写一个文件来存储我的动画曲线(例如作为文本文件),要么我想办法在启动时读取动画。
我试着用
AnimationUtility.GetCurveBindings(AnimationCurve);
Run Code Online (Sandbox Code Playgroud)
它在我的测试中有效,但在某些页面上它说这是一个“编辑器代码”,如果我将项目构建到独立程序中,它将不再起作用。真的吗?如果是这样,有没有办法在运行时获得曲线?
感谢 Benjamin Zach 的 clearify 和 TehMightyPotato 的建议,我想保留在运行时修改动画的想法。因为它可以适应更多情况imo。
我现在的想法是编写一段编辑器代码,可以在编辑器中读取曲线并将有关曲线(关键帧)的所有必要信息输出到文本文件中。然后在运行时读取该文件并创建新曲线以覆盖现有曲线。我将把这个问题保留几天,然后检查它,看看是否有人对此有更好的想法。
I have an array of buttons used to select items from an array. What I'm trying to do is use one function to handle this, like the code below, instead of writing a lot of functions just doing a small job.
However, it seems all of those buttons are set to the last i and it gives an "array out of bound" exception every time I click on the button.
Is there any better way to do this?
I considered …