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
0
Question by Excrubulent · Apr 27, 2012 at 04:01 AM · custom-inspectorlayermaskunitysteer

LayerMasks are inconsistent between different types of Inspector control.

So I've got a script GlobalFlockPropertyManager that manages the properties for a large number of member scripts that all need to be identical. The scripts that I'm managing are things like SteerForAlignment, which come from the UnitySteer 2.2 package.

I'm trying to set a LayerMask from the script onto all of the GameObjects, and I'm getting some strange results. Using the inspector, I set the LayerMask on the GlobalFlockPropertyManager to "Neighbors". The script then propagates the LayerMask value to all of the scripts it's managing, but their LayerMasks appear in the inspector as "Default, Unnamed 3".

Using the debug log, I've confirmed that the LayerMask's int values are all 9, but they still report different names in the inspector.

However, if I set the individual member scripts' LayerMasks to "Neighbors", then the int value that they report is 512.

I'm using a custom inspector for GlobalFlockPropertyManager, so that might be causing it. When I use the drop-down list to select the layers in GlobalFlockPropertyManager, I see a bunch of layer options, plus "Add Layer". This control is created by:

 Target.LayersChecked = EditorGUILayout.LayerField("\t\t\tLayers Checked", Target.LayersChecked);

When I use the drop-down lists for the member scripts, which are created by the default inspector, I see the same layer options, without "Add Layer", but with "Nothing" and "Everything" added.

Basically I want to understand why the int values and the reported layers are different for the two different inspector windows.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Novack · Jul 05, 2012 at 11:21 PM

The problem is that you need to get a bit mask to correctly apply a Layer.

From the Layer documentation:

 // Bit shift the index of the layer (8) to get a bit mask
 int layerMask = 1 << 8;

So in the case above, the layer index was 8, replace that for the layer int index you want to set and then you can change the layer.

Comment
Add comment · Show 1 · 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 Excrubulent · Aug 14, 2012 at 04:44 AM 0
Share

I'm not sure how your answer explains the appearance of the layers in the inspector, or the inconsistency between different ways of applying a layer mask.

I'm not manually applying layer masks, I'm just copying them from one layer mask to another. I'm aware that the layer masks aren't actually meant to be read as ints, I'm just describing the int representation.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Tag mask dropdown like Layer mask 1 Answer

how and where can i download unity steer? 3 Answers

UnitySteer - Increase turning angle 0 Answers

Can DrawDefaultInspector keep its formatting? 1 Answer

Simple Custom editor using Handles.PositionHandle does nothing. Please help! 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