- Home /
Changing array of display images with other set of images on user button press event
Hey all,
I am working on developing an random event based game and using Unity5.5.1f1. Where user have to click on image and see if the given image is already present in a grid or not.I want to make it more interesting after each selection these 6 image shown to user should change. My current code is -
public void BuildList()
{
GUILayout.BeginHorizontal();
while (score < finalScore)
{
foreach (Card card in cardShow)
{
if (GUILayout.Button(Resources.Load(card.Name) as Texture, GUILayout.Width(100)))
{
Debug.Log("image clicked " + card.Name);
int res = Coordinate(card.Name);
Debug.Log("loc in arr " + res);
if (res != -1)
{
int cl = res % 3;
int rw = res / 3;
score += (rw + 1);
Debug.Log("col " + cl + " row " + rw);
Card cd = aGrid[rw, cl];
cd.Name = card.Name;
GUILayout.Box(Resources.Load(cd.Name) as Texture, GUILayout.Height(100), GUILayout.Width(100));
}
else
{
score += res;
}
Wait();
Debug.Log("score " + score);
}
}
}
GUILayout.EndHorizontal();
}
I want the image which are shown to user should change after each click. When I try to do in OnGuI by calling this function by randomizing cardShow array it shows new 6 image side by side. But I want it to draw new images on previous shown array of image But when i choose to blank the screen by
GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));
// UnityEngine.UI.Graphic.SetAllDirty();
GUILayout.EndArea();
It shows a blank screen but didn't redraw and task manager shows processor getting eaten up.
Comment