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 Techsuport 1 · Oct 18, 2010 at 06:02 PM · editorinputvariablecustomization

customization of variables in script for in Editor?

how can i make something like this work? (For, in Editor, customization options of variables of script in Editor)

var haveOption:boolean=false;//used to toggle option
if(haveOption==true){
   var optionVariable:float=42;//if true make option available in editor and used by script
}
function Update(){
   if(haveOption){
DoStuffWith(optionVariable);
   }
}

I want this option to make available various customizable arrays for information input. For example, in the editor, being able to change a variables number, and have that amount of arrays with another variable for each to name each array variable. Plz comment on this concept! =D

-Tech

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 skovacs1 · Oct 18, 2010 at 06:20 PM 0
Share

You question is fairly ambiguous. Consider rephrasing for clarity.

avatar image Jessy · Oct 18, 2010 at 10:05 PM 0
Share
  • for posting on the forum also. Put your internet clutter where the sun don't shine!

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by skovacs1 · Oct 18, 2010 at 07:07 PM

To expose a custom class in the editor, you would use the Serializable and rarely the SerializeField attributes. Public primitive types and Unity classes will serialize automatically and types which are given the Serializable attribute as well as arrays of such types. The System.Object should have this attribute and therefore in javascript, extending the System.Object (or one of the other know serializable types) will give the Seraializable attribute.

Non-typed containers and containers of typed containers will not serialize in and of themselves. To serialize a container of a non-serializing type, you would need to make the type serializable:

public class TransformArray extends System.Object { var array : Transform[]; }

var array : Transform[][]; //Will not serialize; var array2 : TransformArray[]; //Will serialize;

To make a CustomEditor to edit a specific class is fairly simple (See the example in Editor).

Through the broken English, it almost reads as though you are suggesting dynamically building a class editor to create new struct classes. Is this what you are suggesting?

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 Cyb3rManiak · Oct 18, 2010 at 07:43 PM

I think he means exposing one variable in the inspector, that by changing it will show expose other fields in the inspector... Like several operation modes for one class, each exposing different variables that relate to that mode.

And if that's the case SerializedProperty is a good solution for that. The example shows you can expose one private variable of the transform class. You can expose pretty much whatever you want, based on whatever you want.

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

No one has followed this question yet.

Related Questions

3dconnexion - Delta joystick input 0 Answers

Hide public field on base class but show it on derived class 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Platform Input Controller Script NullReferenceException stopping character from moving, can anyone fix this? 1 Answer

[Unity Editor] Emulate Touch Input - Still Asking 12/10 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