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.

38 lines
1001 B

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