How to change Sprite Image when it reaches 90 degrees?
I say that I am a beginner.
I have a question during the project.
I'm currently implementing a card-matching game.
When I start the game, The image is loaded from the external path (D: / ..).
My question is in the code below.
public void createCardList()
{
int count_x = 0;
int count_y = 0;
GameObject parent_area = GameObject.Find("GameMain");
List<int> num = createRandomIndex(createArrayIndex());
for (int i = 0; i < card_list.Count; ++i)
{
if ((i % CARD_ROWS) == 0 && i > 0)
{
count_y += 1;
count_x = 0;
}
GameObject card_prefab_load = Resources.Load("Prefabs/card") as GameObject;
GameObject card_prefab_instantiate = Instantiate(card_prefab_load, card_prefab_load.transform.position, Quaternion.identity);
float card_position_x = (CARD_WIDTH + CARD_SPACE) * (i % CARD_ROWS) - 290f;
//Debug.Log("card_position_x" + card_position_x);
float card_position_y = count_y * (CARD_HEIGHT + CARD_SPACE) - 280f;
//Debug.Log("card_position_y" + card_position_y);
card_prefab_instantiate.transform.SetParent(parent_area.transform);
card_prefab_instantiate.transform.name = "card_" + num[i];
card_prefab_instantiate.transform.localScale = new Vector3(1f, 1f, 1f);
card_prefab_instantiate.transform.localPosition = new Vector3(card_position_x, card_position_y, 1f);
StartCoroutine(firstRotateOriginalImage());
}
}
// Rotate image
private IEnumerator firstRotateOriginalImage()
{
yield return new WaitForSeconds(2f);
GameObject findCardList = GameObject.Find("GameMain");
for (int i = 0; i < findCardList.transform.childCount; ++i)
{
// I don't know what code to put in this part.
}
}
What I want to implement is below.
1.When the card rotation value reaches 90 degrees,How to change an externally imported image to a Sprite Image of a child GameObject?
2.How to rotate the child objects 360 degrees after the first task is completed?
For example, the picture below. Arrows indicate the order in which cards are flipped. also, Of the 12 GameObjects, Six GameObjects try to implement a common image.
I don't know much. I need your help.
Your answer
Follow this Question
Related Questions
clicks pass through UI elements on android 1 Answer
Unity Gradle Build Error 2019.3.10f 0 Answers
Can not load the next scene 0 Answers
Can't change an object Layers at runtime via c# code (Help Please) 0 Answers
Getting trouble in migrating the Unity IAP old version to new version of IAP in existing project 0 Answers