// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Debug.Log("GilLog - CubeSelectionManager::Update - Mouse is down"); RaycastHit hitInfo = new RaycastHit(); bool hit = Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo); if (hit) { Debug.Log("GilLog - CubeSelectionManager::Update - hit " + hitInfo.collider.gameObject.name); CubeSelection cubeSelection = null; if ((cubeSelection = hitInfo.collider.gameObject.GetComponent <CubeSelection>()) != null) { SelectCubes(cubeSelection.CubePosition); } } } }
public List <CubeSelection> GetCubesFrom(Vector3 cubePosition, Vector3 rotationFace) { List <CubeSelection> cubes = new List <CubeSelection>(); Vector3 rotationSet = Vector3.one - rotationFace; // (1,1,1) - (0,1,0) cubePosition.Scale(rotationFace); int posx = 0, posy = 0, posz = 0; sumCube = Vector3.zero; CubeSelection cubeSelection = null; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { posx = (int)(rotationSet.x * x + cubePosition.x); posy = (int)(rotationSet.y * y + cubePosition.y); posz = (int)(rotationSet.z * z + cubePosition.z); cubeSelection = cubeMatrix [posx, posy, posz].GetComponent <CubeSelection>(); if (!cubes.Contains(cubeSelection)) { cubes.Add(cubeSelection); } } } } return(cubes); }