Search Unity

Is there a way to compare playables for equality?

Discussion in 'Animation' started by GreatTreeGames, May 21, 2021.

  1. GreatTreeGames

    GreatTreeGames

    Joined:
    Apr 11, 2018
    Posts:
    1
    It seems a little strange that I can't see if a playable is equal to another one.

    in the code below, mixerPlayable.GetInput(i) == playable is not a valid statement. is there another way?

    Code (CSharp):
    1.  public static int getIndexofThisPlayableInMixer(this Playable playable, AnimationMixerPlayable mixerPlayable)
    2.     {
    3.         for (int i = 0; i < mixerPlayable.GetInputCount(); i++)
    4.         {
    5.             if (mixerPlayable.GetInput(i) == playable)
    6.             {
    7.                 return i;
    8.             }
    9.         }
    10.         return -1;
    11.     }



    Thanks to anyone who can help.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    You could try calling GetHashCode on both of them and comparing that.

    Out of curiosity, what are you using that method for? I haven't ever needed something like that in Animancer.