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 arelian11 · Mar 10, 2015 at 08:48 PM · inspectoreditor-scriptinghideflags

Bug with displaying components in Inspector after hideFlags.NotEditable?

Hey everyone! I've been running into a strange bug lately, maybe someone has seen something like it before.

In messing around with object hideFlags, (specifically NotEditable), I've managed to break the inspector. What appears is this:

alt text

What I expect is this:

alt text

It seems like toggling the hide flags on and off sometimes fixes the issue, but has anyone else run into this before and have a reliable fix?

Here is the code I'm using to do the toggle:

 private static void ProjectWindowItem_OnGUI(string guid, Rect drawingRect) {
     GameObject asset = (GameObject)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath (guid), typeof(GameObject));
     if (asset) {
         if (PrefabEditor.IsEditing()) {
             // Set the NotEditable flag. (| bitwise or)
             asset.hideFlags = asset.hideFlags | HideFlags.NotEditable;
         } else {
             // Clear the NotEditable flag. (& bitwise and) (~ bitwise negate)
             asset.hideFlags = asset.hideFlags & ~HideFlags.NotEditable;
         }
     }
 }

screen-shot-2015-03-10-at-113803-am.png (44.3 kB)
screen-shot-2015-03-10-at-113753-am.png (48.2 kB)
Comment
Add comment · Show 3
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 arelian11 · May 07, 2015 at 09:11 PM 0
Share

Still looking for help on this!

avatar image Bunny83 · May 07, 2015 at 09:45 PM 1
Share

Well, i don't really get what's your actual goal. When and why do you want to set the hideflags to NotEditable? I think the main problem is that you set the hideflags for the GameObject and not for it's components. You shouldn't set it for the GameObject at all.

You should add more details about your script and what you actually want to do. Is this used in a plain editor script, an EditorWindow, PropertyDrawer, custom inspector?

avatar image arelian11 · May 07, 2015 at 10:00 PM 0
Share

I wrote a tool to allow designers at our company to edit prefabs by double clicking them in the project window. It opens up a new scene with that prefab instantiated. The designer can then modify the prefab to their liking and hit a button to save it back to the project asset.

$$anonymous$$y goal with this particular hideFlags feature was to reduce the chance for designer error by only allowing the prefab that is currently instantiated in the scene to be editable. Any prefabs in the project window should not be editable during this time.

After grabbing out the child components and setting the hideFlags on each of them directly and not the gameObject itself, it looks like it fixed the visual error that was happening, and still fufils my requirement. Thanks for the help! :D (You can go ahead and write an answer if you'd like, I'll accept it.)

1 Reply

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

Answer by Bunny83 · May 07, 2015 at 10:11 PM

The hideflags are a bit tricky. While they are available for every UnityEngine.Object derived type not all combinations work or make sense for every type. You usually don't want to use NotEditable on a GameObject, only on components.

If you want to prevent editing in general you might want to set it to HideInInspector and HideInHierarchy. Though be careful with those since you can litteraly hide assets / objects from the project.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to record hideFlags for Undo/Redo 0 Answers

Editor: How to display properties in inspector based on enum in same script ? 1 Answer

missing (transform) vs none: how to code this or query for it? 1 Answer

Custom Inspector Enum 1 Answer

Custom ordering of variables in inspector when using base and derived classes 1 Answer


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