This way, you don't need to keep switching to play-mode when creating an animation that moves an IK target.
To achieve this, I made the script execute in edit mode, except for the part that applies the transformations to the GameObjects. I then rewrote OnDrawGizmos() so that it looks at the Positions[] array, instead of the GameObject transforms.
I also made some other changes to make it behave nicer in edit mode:
It now calls Init() in LateUpdate() when BonesLength is null, in case the script was disabled and missed its Awake() event.
Init() no longer creates a new Target object if Target is null. This avoids cluttering the scene(or worse, the prefab) with tons of GameObjects before the user has had a chance to assign the target.
Turns out there are some mistakes that I didn't catch before submitting the pull request. I'll reopen it once I'm more confident that I didn't introduce any errors.
This way, you don't need to keep switching to play-mode when creating an animation that moves an IK target.
To achieve this, I made the script execute in edit mode, except for the part that applies the transformations to the GameObjects. I then rewrote OnDrawGizmos() so that it looks at the Positions[] array, instead of the GameObject transforms.
I also made some other changes to make it behave nicer in edit mode:
It now calls Init() in LateUpdate() when BonesLength is null, in case the script was disabled and missed its Awake() event.
Init() no longer creates a new Target object if Target is null. This avoids cluttering the scene(or worse, the prefab) with tons of GameObjects before the user has had a chance to assign the target.