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 thraxST · Aug 26, 2013 at 01:40 PM · editorinspectorpropertydrawer

Customizing Inspector variables.

I have a script that is attached to different types of objects in my game and one of the exposed variables in the script is a bool "EnableProximity". The intention is to make the object active when the player comes within a predefined distance of the object, so I have also exposed a public variable "ProximityDistance" so both can be configured in the Inspector.

Is there anyway to hide or disable the "ProximityDistance" field when "EnableProximity" is not checked?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Xtro · Aug 26, 2013 at 01:58 PM

You must write a custom editor script for your own script. So, you can do what ever you want. Without a custom editor, it's impossible.

Comment
Add comment · Show 3 · 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 Jamora · Aug 26, 2013 at 02:12 PM 0
Share

You have two choices with custom editors: a property drawer or a custom inspector. If you have a variable that requires similar special attention in a multiple scripts, you should go with property drawers. A custom inspector is simpler, but restricted to a specific type (class).

avatar image thraxST · Aug 26, 2013 at 03:10 PM 0
Share

Yeah, I was aware of custom editor, but didn't really want to go that route. I was hoping there would be a PropertyAttribute I could use to set it up.

avatar image Xtro · Jan 30, 2014 at 08:58 PM 0
Share

Can you please mark the correct answer if you fixed that problem?

avatar image
0

Answer by gardian06 · Sep 24, 2013 at 02:59 PM

in your PropertyDrawer for the class grab the property of the bool, and store it (SerializableProperty or var) then using myProp.boolValue like you would any other bool in code

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

How do I implement Draggable Properties with custom Labels in Editor or PropertyDrawer? 1 Answer

How To Draw a PropertyDrawer within a PropertyDrawer 0 Answers

How to assign a field within a PropertyDrawer? 1 Answer

Property Drawers In Serializable Classes - GetPropertyHeight 2 Answers

How to show type text in EditorGUI.ObjectField? 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