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
1
Question by jimjames · Dec 03, 2019 at 10:13 PM · listcustom editoreditor windowgeneric list

Generic List In Custom Editor Window

Hi:

I am trying to make a custom editor window with a grneric list. the same as one in the inspector when you attach it on a gameobject.

  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  using UnityEditor;
  
  [System.Serializable]
  public class Tile
  {
      public GameObject tile; //the tile prefab
      public Color tileColor; //the reffrence of color to instantiate prefab
  }
  
  
  public class LevelGenerator : EditorWindow
  {
  
      public List<Tile> tileList;
  
      [MenuItem("Window/My Editor/Level Generator")]
      public static void ShowWindow()
      {
          GetWindow<LevelGenerator>("Level Generator");
      }
  
      //window code
      void OnGUI()
      {
          tileList = EditorGUILayout.List<Tile>("Tile", tileList); //Having trouble with this part!!!
      }
  }


I am thinking it has to do with "propertyfields" but having trouble implementing it.

Thanks: James

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

2 Replies

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

Answer by jimjames · Dec 09, 2019 at 04:33 AM

I got this to work with placing this part of code in the area where i wanted the list to show up in the editor.

         //to show the list of tiles//
         ScriptableObject target = this;
         SerializedObject so = new SerializedObject(target);
         SerializedProperty stringsProperty = so.FindProperty("tileList");
 
         EditorGUILayout.PropertyField(stringsProperty, true);
         so.ApplyModifiedProperties();
         //end for the list of tiles
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 DancingZombie · May 26, 2020 at 06:31 AM 0
Share

@jimjames Thanks for this as i am now able to see my list in the custom editor, the problem i am having is that the list is not editable from the editor, it is grayed out. Did you have this issue and do you have any solutions? alt text

capture.png (24.4 kB)
avatar image
0

Answer by HyruleDefender · May 06 at 07:42 PM

I have been searching for a solution for this here in 2022

And I just replaced "tileList" with the name of myList Thank you, Thank you!

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 unity_0DyuK5ODU55k4w · May 20 at 12:45 PM 0
Share

Hi, could you please show how you came to this? I can now view the list, but cannot assign anything to it in the editor window...

avatar image HyruleDefender unity_0DyuK5ODU55k4w · May 20 at 03:19 PM 0
Share

Sure, Id be happy to.

This is essentially what I have for the array of game objects (I tried to upload a screenshot of the tool, but Unity Answers is not letting me)

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 
 public class MLET_Tool : EditorWindow
 {
 
  //model list
     [SerializeField]
     private List<GameObject> listModelGeo;
 
  //UI visuals
     public void OnGUI() // these should send information ON "spawn grid" for most, but "on change" for some (like rotation)
 {
 
  GUILayout.Label("Prefabs/Models", EditorStyles.boldLabel);
         //to show the list of geo
         ScriptableObject target = this;
         SerializedObject so = new SerializedObject(target);
         SerializedProperty stringsProperty = so.FindProperty("listModelGeo");
 }
 
 
 }

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

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

Related Questions

A node in a childnode? 1 Answer

Performance of FindGameObjectsWithTag vs Lists? 2 Answers

Editor Window Edit property of items in a list 1 Answer

How to create a drag drop area in custom Editor Window to accept texture assets from Project panel 0 Answers

How to include a custom editor in every project? 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