void validateData() { if (_spriteAnimator == null) { _spriteAnimator = target as SpriteAnimator; _spriteRenderer = _spriteAnimator.GetComponent <SpriteRenderer>(); _animationNames = _spriteAnimator.animations.Select(a => a.name).ToArray(); // prep the Play Animation on Start list which needs a "none" var tempNames = new List <string>(_animationNames); tempNames.Insert(0, "None"); _animationNamesForInspector = tempNames.ToArray(); if (_spriteAnimator.playAnimationOnStart != string.Empty) { for (var i = 0; i < _spriteAnimator.animations.Length; i++) { if (_spriteAnimator.animations[i].name == _spriteAnimator.playAnimationOnStart) { _selectedAnimation = i; break; } } } // set the animation for the preview _currentAnimation = _spriteAnimator.animations.Where(a => a.name == _animationNames[_selectedAnimation]).First(); } }
protected void Awake() { anim = GetComponentInChildren <SpriteAnimator>(); outline = anim.GetComponent <SpriteOutline>(); shadow = transform.Find("Shadow") != null?transform.Find("Shadow").GetComponent <SpriteRenderer>() : null; AnimationEventManager.OnDamageTaken += Damage; AnimationEventManager.OnDeath += Death; }
void validateData() { if( _spriteAnimator == null ) { _spriteAnimator = target as SpriteAnimator; _spriteRenderer = _spriteAnimator.GetComponent<SpriteRenderer>(); _animationNames = _spriteAnimator.animations.Select( a => a.name ).ToArray(); // prep the Play Animation on Start list which needs a "none" var tempNames = new List<string>( _animationNames ); tempNames.Insert( 0, "None" ); _animationNamesForInspector = tempNames.ToArray(); if( _spriteAnimator.playAnimationOnStart != string.Empty ) { for( var i = 0; i < _spriteAnimator.animations.Length; i++ ) { if( _spriteAnimator.animations[i].name == _spriteAnimator.playAnimationOnStart ) { _selectedAnimation = i; break; } } } // set the animation for the preview _currentAnimation = _spriteAnimator.animations.Where( a => a.name == _animationNames[_selectedAnimation] ).First(); } }