-
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/add AnimatorState script for handle animatorState's lifecycle (#552
- Loading branch information
Showing
26 changed files
with
319 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"npmClient": "npm", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"bootstrap": { | ||
"hoist": true | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Animator } from "../animation/Animator"; | ||
import { AnimatorState } from "../animation/AnimatorState"; | ||
|
||
/** | ||
* StateMachineScript is a component that can be added to a animator state. It's the base class every script on a state derives from. | ||
*/ | ||
export class StateMachineScript { | ||
/** @internal */ | ||
_destroyed: boolean = false; | ||
/** @internal */ | ||
_state: AnimatorState; | ||
/** | ||
* onStateEnter is called when a transition starts and the state machine starts to evaluate this state. | ||
* @param animator - The animator | ||
* @param animatorState - The state be evaluated | ||
* @param layerIndex - The index of the layer where the state is located | ||
*/ | ||
onStateEnter(animator: Animator, animatorState: AnimatorState, layerIndex: number): void {} | ||
|
||
/** | ||
* onStateUpdate is called on each Update frame between onStateEnter and onStateExit callbacks. | ||
* @param animator - The animator | ||
* @param animatorState - The state be evaluated | ||
* @param layerIndex - The index of the layer where the state is located | ||
*/ | ||
onStateUpdate(animator: Animator, animatorState: AnimatorState, layerIndex: number): void {} | ||
|
||
/** | ||
* onStateExit is called when a transition ends and the state machine finishes evaluating this state. | ||
* @param animator - The animator | ||
* @param animatorState - The state be evaluated | ||
* @param layerIndex - The index of the layer where the state is located | ||
*/ | ||
onStateExit(animator: Animator, animatorState: AnimatorState, layerIndex: number): void {} | ||
|
||
/** | ||
* Destroy this instance. | ||
*/ | ||
destroy(): void { | ||
if (this._destroyed) { | ||
return; | ||
} | ||
|
||
this._state._removeStateMachineScript(this); | ||
this._destroyed = true; | ||
} | ||
} |
Oops, something went wrong.