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 TSRajesh · Nov 02, 2014 at 08:14 PM · listinspectordictionary

Complex List in Inspector..

This question is actually Twofold.. I am able to display and/or add a single types in a List in the inspector, By declaring the list as public. For Instance, I have a list of AudioClips, and i can add elements and drag-drop audio clips in there. But I also want to associate a text with it, (for dialogue speak & display). But if i make it a list of a class (with those two elements) it doesn't show up in the inspector. Is there a way to make it happen in Unity? (I really want the ability to drag-drop audio clips instead of just doing it in the program).

Next is, What about showing dictionaries in the inspector? (With a key in addition..);

Thanks & Regards

Raj

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 vexe · Nov 03, 2014 at 10:47 AM 0
Share

@TSRajesh, for dictionaries and nested types/lists, check out my framework - You could go crazy with nesting! :D

2 Replies

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

Answer by Bunny83 · Nov 02, 2014 at 09:20 PM

If i got you right all you're missing is the System.Serializable attribute, right?

// C#

 [System.Serializable]
 public class DialogItem
 {
     public AudioClip audio;
     public TextAsset text;
 }
 
 public class SomeBehaviour : MonoBehaviour
 {
     public List<DialogItem> dialogs;
 }

You said text file so i used a TextAsset here. However if you want to input a string in the inspectorm just change the type to string. If you want a larger text area to input a text, you have to write a custom inspector for your SomeBehaviour class or a property drawer for your DialogItem class.

If you need more information, just ask ;)

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 TSRajesh · Nov 02, 2014 at 11:49 PM 0
Share

This got me working for Lists. For Dictionaries, I guess i'll have to start looking into Custom Inspectors. Thanks a Lot.

avatar image Bunny83 · Nov 03, 2014 at 05:07 AM 0
Share

Dictionaries can't be serialized at all. A custom inspector won't help here since a inspector can only work with things that are serialized. If you really need a dictionary, take a look at the new ISerializationCallbackReceiver which allows you to manually map data which can't be serialized to a data type that can be serialized. For example "a Dictionary" -> 2 arrays or Lists.

OnBeforeSerialize has exactly this case as example ;)

avatar image
2

Answer by AVOlight · Nov 02, 2014 at 08:34 PM

Here's a great tutorial from Jasper Flick, that helped me get my head around custom inspectors. Which is what you'll need to create your own list with custom functionality, like having descriptions displayed with each element of your list

Comment
Add comment · Show 1 · 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 TSRajesh · Nov 02, 2014 at 11:49 PM 0
Share

Thanks for the link. That will open up a new avenue for my learning.

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

29 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

Related Questions

A node in a childnode? 1 Answer

Changing Custom Object Variable 1 Answer

Create List of Dictionaries C# 2 Answers

[CustomInspector] add scriptableobject in a list always null 1 Answer

how to split TextAsset into a Dictionary? 0 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