Button showing when array is full

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;

[ExecuteInEditMode]

public class Attack1 : MonoBehaviour 
{
	private ArrayList animStrings = new ArrayList();

	public int maxCombo = 4;

	public bool ShowExecuteButton = false;

	void Start () 
	{
		
	}
	
	void Update ()
	{
		try
		{
			if(Input.GetKeyDown(KeyCode.Mouse1))
			{
				Debug.Log(animStrings.Count);
				animStrings.RemoveAt(animStrings.Count-1);
			}
		}catch(ArgumentException e){Debug.Log(e);}
	}

	void OnGUI()
	{
		if(animStrings.Count < maxCombo)
		{
			if(GUI.Button(new Rect(25, 25, 75, 50), "Attack"))
				SaveAnimations("Attack");

			if(GUI.Button(new Rect(25, 75, 75, 50), "Attack01"))
				SaveAnimations("Attack01");

			if(GUI.Button(new Rect(25, 125, 75, 50), "Attack02"))
				SaveAnimations("Attack02");

			if(GUI.Button(new Rect(25, 175, 75, 50), "Combo"))
				SaveAnimations("Combo");
		}

		if(animStrings.Count == maxCombo && !ShowExecuteButton)
		{
			if(GUI.Button(new Rect(125, 85, 125, 50), "Execute"))
			{
				StartCoroutine(ExecuteAnimations(0));
				ShowExecuteButton = true;
			}
		}

		try{
			GUI.Label(new Rect(125, 300, 100,50), animStrings[0].ToString());
			GUI.Label(new Rect(175, 300, 100,50), animStrings[1].ToString());
			GUI.Label(new Rect(225, 300, 100,50), animStrings[2].ToString());
			GUI.Label(new Rect(275, 300, 100,50), animStrings[3].ToString());
		}catch(ArgumentException e){Debug.Log(e);}

	}

	void SaveAnimations(string anim)
	{
		animStrings.Add(anim);
	}

	IEnumerator ExecuteAnimations(int counter)
	{
		for(int x = 0; x < maxCombo; x++)
		{
			animation.Play(animStrings[x].ToString());
			yield return new WaitForSeconds(1);
		}

		for(int x = 0; x < maxCombo; x++)
		{
			animStrings.RemoveAt(0);
		}

		ShowExecuteButton = false;
		yield break;
	}
}

is this the best method to make the “Execute” button appear when the array is already full and the arraylist appears everytime i clicked a button? since there is an ArgumentException even if i’m just gonna call it in the if statement.

Your problem is the type of collection you are using. Avoid ArrayList. Instead use:

 List<string> listString = new List<string>();

ArrayList stores references to object so you need to cast to the type you need, that is why you get your ArgumentException as something else is expected.

Then you do not need the try/catch.