Hi!
I want to change color of my object every touch. Base colors are (red, blue, yellow, green). Color is changing every touch to next color (red->blue ->yellow->green and after green (if touched) back to red.
I was looking since 2 days for any tips in google but I found only helps with “OnMouseDown” or “key” answers.
(the code is not finished)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour {
// Use this for initialization
void Update()
{
for (int a = 0; a < 4; ++a) {
int fingerCount = 0;
foreach (Touch touch in Input.touches)
{
if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
fingerCount++;
}
GetComponent().color = Color.red;
if (fingerCount == 1)
{
GetComponent().color = Color.blue;
}
if (fingerCount == 2)
{
GetComponent().color = Color.yellow;
}
if (fingerCount == 3)
{
GetComponent().color = Color.green;
}
}
}
}