- Home /
Extend Unity ObjectField / Array function/Gui interface
I like to extend the Unity Editor GUI to make a universal sort function for all Arrays available via Context menu.
Is there a way to extend the ObjectField class or the the class that is controlling the GUI for arrays?
Example:
X different Classes with Arras of different types.
I like to sort the input objects (like a image sequence or data files). Implementing / copping the code for sorting in every time in a new custom editor class is not very efficent.
Can you give an example of what you're talking about? You want to somehow sort all arrays in your scene? As in reorder their elements?
C# has built-in array sorting: http://www.csharp-examples.net/sort-array/
Hope this helps.
Answer by JRule4 · Oct 11, 2012 at 05:50 PM
You can only write CustomEditors for classes that are derived from Component. Arrays are not, so you can't write a generic inspector for them.
You could write an EditorWindow that uses reflection to look up any arrays in a target object. Once the arrays are located they can be modified. Sorting is something special, though, as it requires information on how a list of objects need to be sorted.
Thanks but the idea was to make a universal function for all public visable arays in any calss.
How about my answer in there?
http://50.17.205.126/questions/780158/problem-using-editorguilayoutobjectfield-with-cust.html
Your answer
Follow this Question
Related Questions
Changes not being saved in the Inspector Editor 1 Answer
EditorGUILayout.ObjectField for Array 1 Answer
sort gui button 0 Answers
Split Unity editor to work with extended displays? 0 Answers