Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question GameObject.FindObjectsOfType (need help updating this to Unity 2023.1)

Discussion in 'Editor & General Support' started by RandomCharacters, Jul 12, 2023.

  1. RandomCharacters

    RandomCharacters

    Joined:
    Nov 29, 2012
    Posts:
    262
    So, in Unity 2023.1, they changed things yet again breaking lots of assets. I have thousands of warnings that need to fixed. i got most, but still have a handfull left. One is this.

    TextFxNative[] objects = GameObject.FindObjectsOfType(typeof(TextFxNative)) as TextFxNative[];

    If there is no 's', then I can change it to FindFirstObjectByType. But with the 's', it seems that there is more to it. With the array, it seems that more is needed. Can someone help with the conversion? Most every asset store plugin i have has these issues. thanks.

    Just changing it to 'FindObjectsByType' give an error. There is something else I am missing. Is it as simple as:
    TextFxNative[] objects = GameObject.FindObjectsByType(typeof(TextFxNative), FindObjectsSortMode.None) as TextFxNative[];

    ======================================================
    And here is a second one.
    FindObjectOfType<WaypointManager>(true);

    if I change it to:
    WaypointManager wpManager = FindFirstObjectOfType<WaypointManager>(true);

    Then it says it can not convert the bool over.
     
    Last edited: Jul 12, 2023
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
  3. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Unity didn't break your assets, you did, by upgrading to a version that your assets and code doesn't support. Either switch back to the version that was working, or fix your stuff, you're in charge of that.

    From your post it was obvious that you didn't read the new API.
     
  4. RandomCharacters

    RandomCharacters

    Joined:
    Nov 29, 2012
    Posts:
    262
    Thanks for your help and reply.

    Now, Is there anyone else that knows the answer?