You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
902 B

  1. using UnityEngine;
  2. using TMPro;
  3. using UnityEngine.UI;
  4. public class ColourSquareCollection : MonoBehaviour
  5. {
  6. public Texture colouredTexture;
  7. public GameObject counterScore;
  8. public GameObject colourCube;
  9. public Color currentPlayerColour;
  10. GameObject[] objs;
  11. Renderer abc;
  12. int counter = 0;
  13. void Start(){
  14. //have to first get colour from player, hard code purple in at the moment
  15. colourCube.GetComponent<Image>().color = currentPlayerColour;
  16. objs = GameObject.FindGameObjectsWithTag("Coloured");
  17. counter = 1;
  18. counterScore.GetComponent<TextMeshProUGUI>().text = counter.ToString();
  19. }
  20. public void colourupdatefromMove()
  21. {
  22. counter = 1;
  23. foreach(GameObject a in objs){
  24. abc = a.GetComponent<Renderer>();
  25. if (abc.material.GetTexture("_Albedo") == colouredTexture)
  26. {
  27. counter++;
  28. }
  29. }
  30. counterScore.GetComponent<TextMeshProUGUI>().text = counter.ToString();
  31. }
  32. }