Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 oxium · Jun 07, 2011 at 02:43 AM · listcustom-editortemplateobjectfield

Custom object field of List ?

Hey guys !

Trying to do my own custom editor.. I need to expose / access in the UI a list of float (but note that it could be a list of anything) Unity already supports that natively so you can add/remove/edit template list directly in the editor.. But the question is: Can you do that in your custom editor ??

So basicaly I've tried something like that :

 List<float>     Params;
 Params = (List<float>) EditorGUILayout.ObjectField( "Parameters", (UnityEngine.Object)Params, typeof(List<float>) );


Unfortunately I have a "cannot convert type from List to UnityEngine.Object" compiler error so it looks this is not the correct way of doing that..

I'm pretty sure it's possible.. any help / hint / code / thing would be greatly appreciated ;-)

cheers

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 ckfinite · Jun 07, 2011 at 03:51 AM

Basically, use another data type for your object than a List. What is is saying is that there is no way of converting from a System.Collections.Generic.List to a UntiyEngine.Object, which is true.

What I would do is write a wrapper class for List that extends UnityEngine.Object, like this:

 public class ListWrapper<T> : UnityEngine.Object {
     public List<T> objects = new List<T>();
 }

Then you should be able to use it like this:

 ListWrapper<float>     Params;
 Params = (ListWrapper<float>) EditorGUILayout.ObjectField( "Parameters", (UnityEngine.Object)Params, typeof(ListWrapper<float>) );

Unity might not like the generics, so you might want to replace them if this does not work.

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 oxium · Jun 07, 2011 at 07:39 AM 0
Share

hum.. thanks for that but it doesn't seem to work.. in my custom editor I don't have the float list UI we have when using the default inspector.. it just says None then the type of the object (ListWrapper'1[System.Single]) looks like I'm supposed to select something.. I can't create the list of float right in place.. I'm not sure to be very clear here.. I will try to upload an image if this is possible but basically I have the UI you have when you try to set a GameObject for ex (small icon to use a gameobject in the project..)

avatar image ckfinite · Jun 07, 2011 at 12:47 PM 0
Share

Oh, okay. That code assumes that a ListWrapper object has to be dragged in, and since there is no native editor for somewhat obvious reasons, you don't get one. Your best chance would be (in my opinion) be to write a custom editor for ListWrapper. That array view only appears in the default inspector, and hardly anywhere else, so you will have to recreate it.

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

2 People are following this question.

avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

ALWAYS SHOW DROPDOWN LIST 0 Answers

How to preset a filter on ObjectField's GameObject Selection box 0 Answers

Showing the editors of list elements 0 Answers

Error with GUI.ObjectFeild() 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