private void OnDestroy() { if (bo == this) { bo = null; } }
private void Awake() { //Singleton if (bo == null) { bo = this; } else if (bo != this) { Debug.LogError("There is already a BreakableObject.", bo.gameObject); } piecesPos = new Vector3[pieces.Length]; for (int i = 0; i < pieces.Length; i++) { piecesPos[i] = pieces[i].transform.position; } piecesRot = new Quaternion[pieces.Length]; for (int i = 0; i < pieces.Length; i++) { piecesRot[i] = pieces[i].transform.rotation; } }