Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 DiaaGames · Dec 03, 2018 at 02:17 AM · arrayinspector2d arraydrawer

Renaming Inspector 2D Array Element 0 , Element 1

Hi This is the inspector alt text

As you can see the answer in the forum doesn't work if there is an array inside an array of class Code [System.Serializable] public class DragonsClass {

         [NamedArrayAttribute(new string[] { "Neutral", "Happy", "Sad" })]
         public string[] Annswer0;
 
         [NamedArrayAttribute(new string[] { "Neutral", "Happy", "Sad" })]
         public string[] Annswer1;
 
 
     }
 
     public DragonsClass[] DragonsInLevel;
 

 

Thank you

troubleshoot-forum.jpg (40.6 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Dec 03, 2018 at 05:08 AM

First of all that forum thread is a discussion and it has been pointed out several times that in the specific case that was mentioned it's actually a bad idea to use an array if the array should contain a fix amount of elements. You only want to use an array if you have a variable element count in which case hardcoded element names are just wrong.


The property drawer that JohnnyA has posted is a very simple implementation and yes, it does not support nested arrays since it reads the current element index from the property path and he simply grabs the first index it encounters. This could be improved but as already mentioned it's the wrong approach.


Also, as it has been mentioned in the thread you've linked, Unity does automatically rename the element names if the element represents a class / struct and has a string variable as first element. The element will take the content of that first string variable. That way you can create an actual dynamical array / list.

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 DiaaGames · Dec 03, 2018 at 05:20 AM 0
Share

Thank you but I wanted to use the array because its foldable and easy to deal with specially when you are going to loop through it a lot of times and its true i know how many elements i will use in my array but i don't know how many arrays of it i will use

avatar image Bunny83 DiaaGames · Dec 03, 2018 at 11:47 AM 0
Share

When using a custom serializable class you can also fold and reuse the class in several places.

 [Serializable]
 public class AnswerSet
 {
     public string Neutral;
     public string Happy;
     public string Sad;
 }
 
 [Serializable]
 public class Question
 {
     public string title;
     public AnswerSet answers.
 }
 
 [Serializable]
 public class Questions
 {
     public Question[] items.
 }

Here you can create as many questions as you like. The "answers" can be folded inside each question. The name of each "item" element will be the title given in each question.

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

114 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Array elements are empty in the inspector? 1 Answer

Custom inspector, a multidimensional array of enums 1 Answer

How to correctly use EditorGUILayout.MaskField in multi-edit ? 2 Answers

How to serialize an array of classes 1 Answer

Array on the Inspector 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