Hello, I was wondering if caching strings in the Awake function will increase performance or would it take the same amount of time to call - specifically for calling animations.
Ex:
var walk : AnimationState;
var walkAnim : String;
var _animation : Animation;
var thisTransform : Transform;
function Awake(){
thisTransform = transform;
_animation = thisTransform.animation;
walkAnim = "walk";
walk = _animation[walkAnim];
}
function Update(){
_animation.Play(walkAnim);
}
Basically I’m trying to make my code as optimized as possible - this is just an example. I know strings are expensive to process so I was wondering if caching it this way was any help or if walkAnim will just refer back to “walk” as if the same as using “walk” in the first place.
Also, I use InvokeRepeating(); a lot which is formatted InvokeRepeating(“someFunction”, float, float) so would caching the name of the function help? I’m not sure how to go about testing these very well because I’m still saving up for Pro so no profiler.
Thanks!