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 AntLewis · Feb 15, 2013 at 08:05 PM · transforminspector

Removing transform from Inspector

Hi there, I've written a GUI script which positions elements based on their viewport positions. As such, I don't want to (mistakenly) manipulate the transform of the object, so I wondered is there a way to make the objects transform non-editable or not appear at all in the inspector? Cheers!

Comment
Add comment · Show 2
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 lacost · Feb 15, 2013 at 08:19 PM 0
Share

not shure, but did you try to use Destroy, or override transform geter?

avatar image Bunny83 · Feb 15, 2013 at 08:44 PM 0
Share

@lacost: Destroy makes no sense since every GameObject has a Transform. when you try to destroy it you will get an error that you can't destroy it. The transform property has nothing to do with the Transform inspector. The property is just a shortcut for GetComponent

1 Reply

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

Answer by Bunny83 · Feb 15, 2013 at 08:37 PM

I wouldn't recommend to completely lock the transform. I would do something like this:

 void Reset()
 {
     LockTransform();
 }

 [ContextMenu("lock transform")]
 void LockTransform()
 {
     transform.hideFlags = HideFlags.NotEditable;
 }


 [ContextMenu("unlock transform")]
 void UnlockTransform()
 {
     transform.hideFlags = 0;
 }

This will automatically lock the Transform component in the inspector when this script is attached or resetted (the Reset function). Additionally you can right click your script to lock and unlock the transform if it's necessary.

It is also possible to completely hide the transform component, but again, it's never a good idea to hide things. If the user doesn't know it's there it's just confusing.

To completely hide the Transform use those value:

 HideFlags.NotEditable | HideFlags.HideInInspector | HideFlags.HideInHierarchy;
Comment
Add comment · Show 4 · 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 Bunny83 · Feb 15, 2013 at 08:48 PM 0
Share

$$anonymous$$eep in $$anonymous$$d that you can still move / scale / rotate the object with the scene handles and you can still change the parent in the hierarchy. It's always better to show a warning message than trying to lock it down. It just breaks the basic workflow.

avatar image AntLewis · Feb 16, 2013 at 12:37 PM 0
Share

Thanks for the response and code Bunny - one thing you mention interests me, " It's always better to show a warning message than trying to lock it down. It just breaks the basic workflow." I see your point, so is it possible to display a message when editting the transform? Thanks again

avatar image Bunny83 · Feb 17, 2013 at 01:45 AM 0
Share

Well, there are several ways. One would be to remember the position you set from your custom script and whenever you access the position again, check it against your cached data. If it's different show a warning and if it's important that the objects need to use it's original position, revert it to your saved position.

If you want immediate feedback, implement a custom inspector for your class and hook into the update delegate or use any of the callbacks you have in your custom inspector and do the check there.

avatar image AntLewis · Feb 18, 2013 at 11:47 AM 0
Share

Ok Bunny, thanks again!

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

11 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

Related Questions

Why does the Transform component look like Image 1, instead of the standard one (Image 2) in the Inspector window? 1 Answer

Fold/unfold gameobject from code 4 Answers

Transform.rotate gives different result to rotation in inspector 0 Answers

How can I see the normal transform inspector 1 Answer

Inspector window transform component showing ONLY local cordinates 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