I have seen plenty off toggle examples - in fact that is how I got a light to toggle. but now I want to apply that same principle to an animation which I can’t find any examples. I understand the light toggle script but can’t figure out how to adapt that to an animation toggle script. I think I need to see if the first animation has already played . so below is a section of the working light toggle script and below that the script that plays animation1. I need it to play animation2 if animation1 has already played. Basically it’s a raycast script so that if I hit mouse1 button while looking at an object it does whatever…toggle a light and I want a toggle animation as well so I can open and close drawers, doors etc
if(hit.transform.gameObject.tag == ("lamp"))
if (Input.GetKeyDown(KeyCode.Mouse1))
if (light.enabled == false)
light.enabled = true;
else light.enabled = false;
//______________animation toggle__________________________
if(hit.transform.gameObject.tag == ("door"))
if (Input.GetKeyDown(KeyCode.Mouse1))
animation1.Play("doorOpen");
I can help, @shadowpuppet!
I don’t entirely follow your question; that to say correct me of I’m off the mark and we’ll make the internet a slightly more useful place for anyone who finds themselves here 
The Approach
Have an object that holds the script in order to control the toggle-able sprite animation.
Upon a condition, toggle on. Maybe on another, toggle off.
If you’re only wanting to toggle the animation and leave the sprite (or whatever control is on your Animator object) on, just ignore what I’m naming yourSpriteYouAreTogglingAnimationFor entirely.
Animator animation1;
SpriteRenderer yourSpriteYouAreTogglingAnimationFor;
void Start ()
{
ToggleAnimator(false);
}
GameObject hit;//not sure what it is, but you do!
void OnMouseEnter()
{
bool aCondition = true;//hit.transform.gameObject.tag == ("door");
bool maybeAnother = Input.GetKey(KeyCode.Mouse1);
if(aCondition && maybeAnother)
ToggleAnimator(true);
}
internal void ToggleAnimator(bool toggleTo)
{
animation1 = GetComponentInChildren<Animator>();
yourSpriteYouAreTogglingAnimationFor = animation1.gameObject.GetComponent<SpriteRenderer>();
animation1.enabled = toggleTo;
yourSpriteYouAreTogglingAnimationFor.enabled = toggleTo;
}
void OnMouseExit()
{
animation1 = GetComponentInChildren<Animator>();
yourSpriteYouAreTogglingAnimationFor = animation1.gameObject.GetComponent<SpriteRenderer>();
if(animation1.enabled && yourSpriteYouAreTogglingAnimationFor.enabled)
ToggleAnimator(false);
}
This approach also allows other scripts to toggle the animated sprite; scriptClass.ToggleAnimator(true || false); in this case. I’d just tested this scenario that I believe is what you’re describing and I find it succeeds to toggle on the object if you’re holding right click when the event OnMouseEnter is called, and toggle off when no longer hovering over it.