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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Unity Editor - Add Find and Replace for GameObject(s)

Discussion in 'Editor & General Support' started by master_rigel, Jul 28, 2018.

?

Do you think the unity editor should have built in search and replace?

  1. Yes

    72 vote(s)
    100.0%
  2. No

    0 vote(s)
    0.0%
  3. You have a different idea

    0 vote(s)
    0.0%
  1. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    Umm. Why is there no way to search and replace GameObjects in the Unity Editor?

    1. Select all applicable gameObjects.
    2. Click the edit menu
    3. Click replace GameObject with (or Something Similar)
    4. Select the GameObject you want to replace the current GameObject(s) with
    5. Click Apply.

    6. In the background Unity breaks the prefab, replaces the gameobjects and re-attaches the prefab

    7. All instances of your GameObject are replaced with the new GameObject.

    The classes for this already exist in the Untiy Editor.

    Unity Technologies just has to implement it as a menu option.
     
    Last edited: Jul 28, 2018
  2. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    BTW: Does anyone know how to change the value of the polling question field?
     
    Last edited: Jul 28, 2018
  3. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
  4. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    That's not the point!

    If it can be done with an editor plugin, then the methods are already in the Unity Engine!

    I Just wish Unity would build the functionality into the release builds, instead of making me go find a plugin.
     
  5. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Pretty much all unity editor plugins are made using methods already in the unity engine. By that logic, all plugins should be integrated into the editor by default.

    Maybe there are some gaps in the foundational feature set that ships with the editor, but the benefit of having such a robust editor api is that those gaps are easily filled. The unity team is much smaller than the entire unity community. The fact that we actually have a redress for missing features beyond complaining about them is a massive mark in Unity's favor. Additionally, what metrics decide what features are important or ubiquitous enough to implement into the editor versus leave as a plugin? It's a difficult question, and you'll never get everyone to agree on an answer. Maybe they're not implementing the features you want, but if they were, then they'd in turn not be implementing the features someone else wanted.

    My personal view is that something as fundamentally simple to implement as replacing objects (especially since you don't even have to implement it! It already exists!) isn't something that is worth taking precious time away from other critical features or fixes.
     
  6. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    Madgvox. The script you linked me to doesn't work. It doesn't inherit from MonoBehavior. It's a dead goose. Sorry.
     
  7. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    MonoBehaviour isn't the only way to add functionality to Unity. It inherits from ScriptableWizard, and adds a menu item in the GameObject menu, under
    GameObject > -Replace Selection...
    .

    Also make sure you put it in an Editor folder.

    From the page I linked:

    Place this script in YourProject/Assets/Editor and a menu item will automatically appear in the 'Game Object' menu after it is compiled.​
     
  8. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    Yep. That works. Sorry for the gripe.
     
    Madgvox likes this.
  9. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    No problem, I can certainly commiserate with the frustrations of coding!
     
  10. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    In other news, I need to remember to read code comments. It's in there, and I did this all last night, but wanted to see if I could optimize the code. My C# is rusty at best. I haven't used it in 10 years honestly. I'm just coming back to game development now, after 10+ years in web development. I'm still used to PHP and SQL.

    Sorry about that.
     
  11. master_rigel

    master_rigel

    Joined:
    Mar 24, 2014
    Posts:
    69
    Uh Oh. I found an error! Is signing up for the Unify Wiki free to all users?

    EditorUtility needs to be updated to PrefabUtility.

    EditorUtility is Obsolete but not removed yet.

    I updated it in my script.
     
  12. LoveraSantiago

    LoveraSantiago

    Joined:
    Nov 20, 2017
    Posts:
    18