virtual protected void DoDestroy() { aiBase = gameObject.transform.parent.GetComponentInChildren <AIBase>(); GameObject patrolObject = aiBase.GetPatrolObject(); if (aiBase != null) { Destroy(patrolObject); } SpawnManager spawnManager = GetComponentInParent <SpawnManager>(); if (spawnManager != null) { AIBase aiBase = spawnManager.GetSpanwerAI(); if (aiBase != null) { aiBase.DeductSpawn(); } } GameObject temp = Instantiate(Resources.Load("General/EnemyDestroy")) as GameObject; temp.transform.position = transform.position; spriteRenderer.color = new Color(1f, 1f, 1f, 0f); Destroy(gameObject.transform.parent.gameObject); }