Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Matt O. · Dec 04, 2013 at 12:21 PM · 4.3

Selection.activeOject remains NULL

I have a script that I run from a menuItem. After I select an asset folder in the project view, I run the script from the context menu there.

First thing I do is determine which asset I had selected using

 Object selected = Selection.activeObject;

But since upgrading to 4.3 the activeObject remains NULL, and so do the other properties of the Selection object. I've had this script working from Unity 3.5 up to 4.1.

What could be the issue here? Or should I grab the selected Object in a different manner now?

Comment
Add comment · Show 1
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 Matt O. · Dec 04, 2013 at 04:11 PM 0
Share

fwiw: I'm using 4.3.1f1 on Windows 8.0

2 Replies

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

Answer by MrCranky · Dec 04, 2013 at 04:41 PM

Using 4.3.0f4, on Mac OS X, I'm seeing Selection.activeObject definitely returning non-NULL results. A simple Editor window with a label showing me the ToString() value of the Selection.activeObject shows it changing as I select things. But...

I think it depends on what you're selecting. If you're selecting something in the left-hand pane of the Project view (i.e. the folder tree), the Selection.activeObject does not change at all. Only the right-hand pane contents change. However if you select a folder in the right hand view (e.g. click on Assets in the left pane, then a sub-folder of Assets in the right-hand pane, then you should find that Selection.activeObject is an object of type UnityEnginee.DefaultAsset).

However if you then go on to select a different folder in the left hand pane, the Selection.activeObject remains the folder you originally selected in the right-hand pane. I.e. the left-hand pane is nothing to do with the Selection class. It's just a way of organising your assets. I presume that the context menu on a folder in the left-pane is the same one you'd get if you clicked in the empty space in the right-hand pane. But if you want Selection.activeObject to be the folder you're looking at in the right-hand pane, you actually have to go up one level in the tree, and select the folder from the parent listing before right clicking to get a context menu.

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 Matt O. · Dec 05, 2013 at 08:54 AM 0
Share

Thank you, this solved it for me. I guess there was a fix since the documentation never specified that the left pane would change the selection, but it did in the past.

avatar image MrCranky · Dec 05, 2013 at 08:59 AM 0
Share

I confess, I jumped straight from 3.6, which had no left pane at all (just a single hierarchical tree with folders and files in the same view) to 4.3, not sure about earlier versions of 4.

avatar image
0

Answer by elijahjns · Jun 12, 2019 at 03:18 PM

I had the error if I select an object with a script before I start. Now I'm having this error if I select lights at all while the editor is running. It's goofy.

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

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

18 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

Related Questions

Cookie Header With WebPlayer Unity3d 4.3 3 Answers

Simple animation on game object doesn't play via animation.Play 1 Answer

Android Anti Aliasing broken with Unity 4.3.0 -> 4.3.2, but works on Unity 4.2. 1 Answer

Performance spikes even with almost empty scene 3 Answers

Detecting Mouse Click on 2D Sprite 4 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