//[Button(ButtonSizes.Large)] private void Update() { cubesWithIndice.Clear(); associateSide.Clear(); var allCube = GameObject.FindGameObjectsWithTag("Cube"); foreach (var item in allCube) { CanBeNextTo sided = item.GetComponent <CanBeNextTo>(); for (int i = 0; i < sided.adjoiningCubes.Count; i++) { if (sided.adjoiningCubes[(Side)i] != null) { for (int j = 0; j < sided.adjoiningCubes[(Side)i].Count; j++) { if (sided.adjoiningCubes[(Side)i][j] == indice) { cubesWithIndice.Add(item); associateSide.Add(new List <Side>()); associateSide[associateSide.Count - 1].Add((Side)i); } } } } } }
public void Check() { CanBeNextTo nextTo = GetComponent <CanBeNextTo>(); List <GameObject> problematicsCubes = new List <GameObject>(); List <Side> problematicsSide = new List <Side>(); for (int i = 0; i < nextTo.adjoiningCubes.Count; i++) { Side side = (Side)i; Side inverseSide = SideHelp.GetInverseSide((side)); for (int j = 0; j < nextTo.adjoiningCubes[side].Count; j++) { GameObject cubeTest = nextTo.adjoiningCubes[side][j]; CanBeNextTo nextToTest = cubeTest.GetComponent <CanBeNextTo>(); bool found = false; for (int k = 0; k < nextToTest.adjoiningCubes[inverseSide].Count; k++) { GameObject cubeTestSecond = nextToTest.adjoiningCubes[inverseSide][k]; if (cubeTestSecond.name.Contains(gameObject.name) || gameObject.name.Contains(cubeTestSecond.name)) { found = true; break; } } if (!found) { problematicsCubes.Add(cubeTest); problematicsSide.Add(inverseSide); } } } if (problematicsCubes.Count > 0) { Debug.LogError("Il y a un problème avec " + name + ", " + problematicsCubes.Count + " cubes ne se comprènent pas, les voici."); for (int i = 0; i < problematicsCubes.Count; i++) { Debug.LogError(problematicsCubes[i].name + " n'est pas associé " + SideHelp.ShowRealName(problematicsSide[i])); } } else { Debug.Log(name + " est tout bon"); } }