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 Bluestrike · Apr 26, 2012 at 08:34 AM · sceneviewhideflags

How can I undo HideFlags.NotEditable;

I have a gameobject with script, the script has a lock boollean and when true it activates gameObject.hideFlags = HideFlags.NotEditable; But how can I undo this when the user want to be able to select and edit the object/script again?

Or is there another way to make a object unselectable in the scene view (preferable scene view only and still availeble in the inspector)

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 Bluestrike · May 21, 2012 at 12:20 PM 0
Share

Found gameObject.hideFlags = (HideFlags)0; but thats not working as it causes an expecting a semicilon error in uniscript.

http://forum.unity3d.com/threads/37956-How-do-I-lock-a-mesh-or-make-it-unselectable

2 Replies

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

Answer by Bunny83 · May 21, 2012 at 12:32 PM

There is no c-style cast in UnityScript. UnityScript casts most things automatically. Just use:

 gameObject.hideFlags = 0;

The HideFlags enum doesn't have a constant for 0 so this is the only way.

 public enum HideFlags
 {
     HideInHierarchy = 1,
     HideInInspector = 2,
     DontSave = 4,
     NotEditable = 8,
     HideAndDontSave = 13
 }

Setting the hideFlags to 8 has the same effect as HideFlags.NotEditable.

edit

Since the hideflags could include other flags as well, it's better to just affect the flags you want

This will toggle the NotEditable flag, so it can be used to set and reset it:

 gameObject.hideFlags ^= HideFlags.NotEditable;
 // which is the same as
 gameObject.hideFlags = gameObject.hideFlags ^ HideFlags.NotEditable;

This is the xor-operator which is perfect to toggle a single bit in a variable.

To set a certain bit you would do this:

 gameObject.hideFlags |= HideFlags.NotEditable;

To reset a certain bit you would do:

 gameObject.hideFlags &= ~HideFlags.NotEditable;

 //   | - bitwise or-operator
 //   & - bitwise and-operator
 //   ~ - bitwise negate
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
avatar image
0

Answer by IzzySoft · Nov 06, 2014 at 10:37 AM

Also, in Unity3D version 4.5.5f, the SceneHierarchyView wont refresh, so wont Hide the object right away. If you want to Hide it, you just have to force a refresh like this:

GameObject go = new GameObject( "GameObject" ); DestroyImmediate( go );

:)

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 peladovii · May 28, 2015 at 03:29 AM 0
Share

Thanks, this was really helpful! still have to do the forced refresh in Unity5

avatar image Deadcow_ · Jul 05, 2017 at 07:08 AM 0
Share

EditorApplication.RepaintHierarchyWindow()?

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

6 People are following this question.

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

Related Questions

How can I set a selection-sphere in the editor 1 Answer

How to select a hidden MeshRenderer in SceneView? 0 Answers

Profiler has HideFlags.DontSave Assets taking up 86mb [What is this?] 1 Answer

HideInHierarchy But Still Selectable 0 Answers

Drawing to scene view from EditorWindow? 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