Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Ryuuguu · Jul 24, 2014 at 05:42 AM · editorscenemonobehaviourassetdatabasesearch

Ho do I find all scenes with a certain script on an GameObject

I want to find all scene that a particular MonoBehaviour on any GameObject. My first plan was to convert all scenes to text serialization and do text search, but That always crashes my Editor with a request for an addition 16GB of ram to convert a Texture2d. Any other methods maybe using AssetDatabase to search Scenes?

I am porting a project with limited support from original code.
500+ scenes.
C# but I don't see why the language matters.
I am just trying to find them in the editor.

I change the serialization on a smaller project to Force text and looked a the .unity files. In those I can see the GUID for each monobehaviour attached to an object. with AssetDatabase.GUIDToAssetPath or AssetDatabase.AssetPathToGUID depending which your going I could find out what Scripts are used in each scene. At worst I could do a quick text search from outside unity. I was hoping to get the information visible in a .unity file when saved as text from AssetDatabase calls.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lucanio · Jul 24, 2014 at 06:34 AM 0
Share

This seems to be more trouble than it's worth. Why do you want to do this? Is there not a simpler solution?

avatar image Andres-Fernandez · Jul 24, 2014 at 06:55 AM 0
Share

How many scenes are we talking about?

avatar image Pendrokar · Jul 24, 2014 at 07:10 AM 0
Share

Which program$$anonymous$$g language are we talking about?

avatar image calebheale · Jul 24, 2014 at 07:21 AM 0
Share

Are you just trying to find them for editing or are you trying to do this at runtime in your actual game?

2 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by airship-brooks · Nov 10, 2015 at 05:37 PM

If you have .meta files turned on, you can open the script's meta file in a text editor and see what the guid is for the script there. You can search for that guid in all your .unity and .prefab files in a text editor.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ryuuguu · Nov 11, 2015 at 01:38 AM 0
Share

Also in project settings > Editor you need to have asset serialization mode set to "force text" I think. That is how I do it now. When I post my question there was bug in version of Unity (a console specific version) I was using that stopped my from switching to force text mode.

avatar image CrandellWS · Mar 03, 2021 at 07:37 PM 0
Share

on Linux with ter$$anonymous$$al this works perfect

 $ grep  -Rni guid 

thanks

avatar image
0

Answer by abdulthegamer · Jul 24, 2014 at 08:18 AM

Hi Ryuuguu,

Sorry to say but there is no way that you can find certain script on GameObeject in any of the scenes in project. Except that you should remember it or check each object and some script may be instatiated.

If you got that then mark this as answer and close this.

Regards.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fafase · Nov 11, 2015 at 05:27 AM 0
Share

In editor, it is possible, you can load a scene, get all objects, get the components into a static array or a file, then load next scene and so on.

Is it worth it? I don't know.

avatar image Ryuuguu fafase · Nov 11, 2015 at 05:55 AM 0
Share

This is how assets on the store do this , it is very slow with large projects.

avatar image fafase Ryuuguu · Nov 11, 2015 at 06:50 AM 1
Share

So yes, it is possible if you want it.

 [$$anonymous$$enuItem ("EditorScript/EditorTest %t",false, 0),]
 private static void EditorTest () 
 {
    List<Script> list = new List<Script>();
    string [] sceneNames = new string[]{"Level1", "Inventory", "$$anonymous$$enu"};
    foreach(string sceneName in sceneNames){
        EditorApplication.OpenScene(sceneName);
        GameObject [] objs = FindObjectsOfType<GameObject>();
        foreach(GameObject obj in objs){
            Script script =  obj.GetComponent<Script>();
            if(script != null){
                list.Add(script);
            }
        }
    }
 }


This in a editor script. You would have to do something with the list at the end.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

29 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do I wait until after AssetDatabase creates an assets before carrying out another function ? 0 Answers

Camera.main.pixel incorrectly return scene view's size in OnDrawGizmos 0 Answers

Determine the Scene that is selected when using context menu 0 Answers

Editor Scene? 1 Answer

Scene Box/Rectangle Editor. Does one exist? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges