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 /
This question was closed Oct 21, 2018 at 10:03 PM by dan_wipf for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by dan_wipf · Sep 11, 2018 at 03:42 PM · editorcustom-inspectorserializedpropertylist of lists

Is it possible to display a List of GameObject List in a Custom Inspector?

Hi. I'm building on a Custom Editor, and got stuck at following List>() .. Is it Possible however to display the List in a Custom Inspector?


my Idea was the Code below.. but what a surprise it doesn't work..


Script:

 List<List<GameObjects>> m_GameObjects;
 
      void OnEnable(){
          m_GameObjects = new List<List<GameObject>>();
      }



Editor:

 MyPersonalScript myTarget;
     SerializedProperty m_GameObjects;
      public void OnEnable()
      {
          myTarget = (MyPersonalScript)target;
          m_GameObjects.serializedObject.FindProperty("m_GameObjects");
      }
      public override OnInspectorGUI(){
          serializedObject.Update();
          for(int i = 0; i< m_GameObjects.arraySize;i++){
              SerializedProperty m_objects = m_GameObjects.GetArrayElementAtIndex(i);
              EditorGUILayout.PropertyField(m_objects,true);
          }
          serializedObject.ApplyModifiedProperties();
      }


I hope somebody could help me out here!


dan

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

  • Sort: 
avatar image
2
Best Answer

Answer by Atiyeh123 · Sep 11, 2018 at 05:04 PM

hi,I don't think so Unity's serialization system doesn't do this , you can't show list of list in inspector. You'll need another type to wrap the array and create a list of that wrapper type instead. you can put the inner list in a script or class. [System.Serializable] public struct GOArray {

         public List<GameObject> gameObjects;
      
         // optionally some other fields
     }
 

then you have your list :

 List<GOArray> list;

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 dan_wipf · Sep 11, 2018 at 05:08 PM 0
Share

thanks for your answer!

well if i put this right in my script, sorry for the noobish and ungoogled question, would i place this right after the monovehaviour{.. section?

avatar image Nikola7007 dan_wipf · Sep 11, 2018 at 05:19 PM 1
Share

It shouldn't really matter where you put it, for the most part.

(Specifically: If you put it inside the $$anonymous$$onoBehavior, then only the code in that monobehavior can access it, so that might be a plus. Unless you intend to use that GOArray in other scripts, in which case, you probably ought to put it outside.)

 public class Something : $$anonymous$$onoBehavior {
 
     [System.Serializable]
     public struct GOArray {
         public List<GameObject> gameObjects;
     }
 
     List<GOArray> listOfLists;
 
 }
 
 // Now, to access it from OUTSIDE the Something monobehavior,
 // you would have to say <Something.GOArray>
avatar image dan_wipf dan_wipf · Sep 11, 2018 at 07:01 PM 0
Share

just wondering is it aswell posible making list of list of list that way? if yes how?

Follow this Question

Answers Answers and Comments

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

Related Questions

Access another objects property in an editor script 1 Answer

How to change inspector with non-Monobehaviour objects ? 1 Answer

Custom Inspector: Using SeralizedProperty changes the prefab values! 0 Answers

Enum Dropdown in JS Using Custom Editor? 2 Answers

Custom Inspector: Accessing a reference to another MonoBehaviour? 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