Array Animation C# Unity

Asked

Viewed 85 times

0

Error in the array of Animation, please see in the video that you will understand, at the time of the change of an object to another it is totally erased.

Video

public Animation[] Animation1;
private int Selecao8;

   public void ProximaSelecao8()
{
   //Animation1 [Selecao8].SetActive (false);
   Animation1[Selecao8].GetComponent<Animation>().Play();
   Animation1[Selecao8].GetComponent<Animation>().enabled = false;
   Selecao8++;
   if (Selecao8 > Animation1.Length - 1) 
   {
      Selecao8 = 0;
   }
   //Animation1 [Selecao8].SetActive (true);
   Animation1[Selecao8].GetComponent<Animation>().Play();
   Animation1[Selecao8].GetComponent<Animation>().enabled = true;
}

   public void AnteriorSelecao8()
{
   //Animation1 [Selecao8].SetActive (false);
   Animation1[Selecao8].GetComponent<Animation>().Play();
   Animation1[Selecao8].GetComponent<Animation>().enabled = false;
   Selecao8--;
   if (Selecao8 < 0) 
   {
      Selecao8 = Animation1.Length -1;
   }
   //Animation1 [Selecao8].SetActive (true);
   Animation1[Selecao8].GetComponent<Animation>().Play();
   Animation1[Selecao8].GetComponent<Animation>().enabled = true;
}
}
  • Hello, welcome to SOPT. I suggest you focus your doubt and make it more objective. The way it is, you can’t know exactly what your difficulty is. For example, in that code current attribute Animation1 is commented and therefore does not exist. The code must be making a compilation error right there. Other than that, the method Play must be invoked directly, for he is not an array. The array is the attribute Animation1, then you should have done Animation1[Selecao8].GetComponent<Animation>().Play(); most likely.

  • I’m just trying to do an array of Animation. For example enable and disable, using the lenght -1.1 in onclicks only that I’m not getting if you can help me or fix what I’m missing would appreciate it very much.

  • I already helped you. Did you read what I wrote? I suggest you try the changes I suggested and if it doesn’t work, go back and edit the question to make your mistake clear. Don’t take this the wrong way, but this site is not a forum and neither is "classified" so you can find someone to do it for you. If you haven’t done yet do the [tour] and read [Ask].

  • kkkkkk ok ok... joking aside, I fixed the error that persisted. only it gave a problem, I will edit the question with the made and the error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.