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
15
Question by hencz · Dec 07, 2010 at 08:08 PM · editorassetprojecthighlight

How to highlight or select an asset in project window from editor script?

Hi

Is there a function for highlighting assets in project window like when I click on a variable of a script in the Inspector? I'm making an Editor script.

Thanks

Comment
Add comment
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

2 Replies

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

Answer by Skjalg · Dec 07, 2010 at 11:15 PM

You could use Selection if you want to mark it in the Project

Selection.gameObjects = new GameObject[] { theGameObjectIwantToSelect };

Or if you want the object to highlight as yellow then you could use PingObject

EditorGUIUtility.PingObject( theObjectIwantToSelect );
Comment
Add comment · Show 9 · 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 hencz · Dec 08, 2010 at 03:46 AM 0
Share

Actually I want to "highlight" it like in this picture: http://img34.imageshack.us/img34/914/77510398.jpg

avatar image Skjalg · Dec 08, 2010 at 02:46 PM 0
Share

I know that if you insert the gameobject that you want to highlight in as the second paramter of Debug.Log("Hi", theGameObjectIwantToSelect); Then it highlights.

I dont of any other ways.

avatar image hencz · Dec 08, 2010 at 05:44 PM 0
Share

It only highlights the object when I click on the message in the console.

avatar image Skjalg · Dec 08, 2010 at 07:36 PM 0
Share

Okay, edited my answer to suit your needs =)

avatar image hencz · Dec 08, 2010 at 08:28 PM 0
Share

It works. thank you

Show more comments
avatar image
27

Answer by grimmy · Oct 22, 2012 at 01:25 PM

Although the above answer seemed to work for many, I couldn't select assets in my project window by following the answer above (only my hierarchy view). However, I managed to select assets by using the following command. Here is an example of selecting a prefab that resides in your Project window.

 Selection.activeObject=AssetDatabase.LoadMainAssetAtPath("Assets/Prefabs/"+prefabName+".prefab");

Hope that helps someone!

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 TimK.Disney · Oct 30, 2013 at 04:14 PM 2
Share

Yeah I'm not quite sure why that got so many upvotes -- I don't think it actually works for objects in the Project tab, or perhaps you could argue that it omits the most important part: how to actually get an object in the Projects tab as a GameObject you can pass to Selection.

I was able to get this to work much the way you did, although I used Resources:

 GameObject prefab = Resources.Load(prefabName);
 Selection.activeObject = prefab;
avatar image markschiemann · Sep 01, 2014 at 10:03 PM 0
Share

Grimmy's AssetDatabase solution worked for me! Tim$$anonymous$$'s Resources.Load approach seems to occasionally not work, perhaps if the user hasn't highlighted the object manually at least once first?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Getting assets / sub folders inside a folder 1 Answer

Getting all assets of the specified type 5 Answers

Multiple object Selection in project view: Unity shows wrong type 0 Answers

How should I organize a project for asset store submission? 2 Answers

Some Text crash after few force closing of Unity Editor 2 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