Advanced Inspector was just accepted over the AssetStore.
However, since it’s a fairly large and complex package, it means that I don’t assume development is done yet. There’s obviously lot of feature I could have forgot, not thought about, or simply never heard of that people would like to see being part of this kind of Inspector re-write package. Of course, there could also be bug I didn’t catch.
Things currently in work;
- 2D/3D preview without the need of custom editor.
- Non-selectable object field (System.Object and derive created) to show ToString of the instance.
- Pre-expansion field creation instead of post-expansion. Right now it affects how prefab overridden value are displayed in nested object.
- More Unity type converted to Advanced Inspector*.
However, the big question would be, what do you want to see in your Inspector?
I know a lot of people would like Dictionary and Interface support, but I’m not ready just yet to jump into alternative serialization when I know another package out there is doing just that. I might add way for editing Dictionary properly, even if Unity doesn’t support its serialization yet, if people have a need for it.
With the release of 4.5 and the new interface “ISerializationCallbackReceiver”, should this package support alternative serialization, or is that new interface enough for people to make their own?
And if now that people can have their own serialization, should the priority shift to displaying interface and dictionary properly, independently of the serialization used?
Version 1.1 will soon be submitted to the Asset Store.
As seen here; http://www.youtube.com/watch?v=EOX6itCuKOc&feature=player_detailpage#t=1180 Unity is rolling out in 4.6 “Action” field as a way to bind an event to a method. We heard lot of people being excited by the features… We wondered if we could do the same, with maybe more option and features, without having to code a custom editor.
So… we did.
Those “ActionBinding” can be placed in a collection too;
[AdvancedInspector]
public class AIExample_Binding : MonoBehaviour
{
[Inspect]
public ActionBinding onClick = new ActionBinding(new Type[] { typeof(Material) } );
[Inspect]
[CollectionConstructor("OnReleaseConstructor")]
public ActionBinding[] onRelease = new ActionBinding[0];
private object OnReleaseConstructor()
{
return new ActionBinding(new Type[] { typeof(Material) });
}
private void OnMouseDown()
{
onClick.Invoke();
}
private void OnMouseUp()
{
foreach (ActionBinding action in onRelease)
action.Invoke();
}
}
They can have an unlimited number of parameters. They support all the types Unity serializes.
Each parameter can work in 3 modes;
- Internal; the argument is passed by the class invoking the action in the Invoke method.
- Static; the argument is manually set in the inspector.
- External; the argument is retrieved from an other method invoked. Only parameterless methods with the proper return type are listed.
And other fixes and modifications coming with 1.1;
- Fixed the Camera preview
- Fixed the Camera perspective/orthographic drop down with new RestrictedAttribute option.
- Added a way to decouple data from description in the RestrictedAttribute. Just pass DescriptorPair instead of the object directly.
- Added a missing constructor in ReadOnlyAttribute.
- Changed the constraint field in the RigidBody because “I prefer the checkboxes”.
- Non-editable expandable field - such as object deriving from System.Object - now display info in the format “ToString() [Class Name]”. Overriding ToString becomes useful.
- Fixed a null in the Restricted > Toolbox.
- SizeAttribute can now flag a collection as not-sortable.
- Added a new Attribute; RuntimeResolve which display a field editor based on the object’s type or a type returned by a delegate, instead of the field type. It can also be used to restrict a Object field to a specific type. For example, you can make a UnityEngine.Object field only display Material.
- Added a new Attribute; CollectionConstructor which let you create a collection item with the constructor and parameter of your choice.
Copy/Paste;
If you ever worked with Cloth, you probably found the kinds of “tabs” at the top useful and rather cool looking. Collection of information sorted by tabs.
Once again, this was done without any custom editor.
[AdvancedInspector(false)]
public class AIExample_Tabs : MonoBehaviour
{
[Inspect]
[Tab(MyTabs.TabA)]
public Bounds itemOfTabA;
[Inspect]
[Tab(MyTabs.TabB)]
public Material itemOfTabB;
[Inspect]
[Tab(MyTabs.TabC)]
public string itemOfTabC;
}
public enum MyTabs
{
TabA,
TabB,
TabC
}
For future release…
With Unity 4.5 and the Serialization Callback, it’s now possible to serialize Dictionary without having to rely on an external serialization. Which means, it’s time to roll out a way for the Inspector to display and edit dictionary properly.
You can see an example of a Dictionary implementation that works right now with Unity 4.5; 4.5 Dictionary - Unity Engine - Unity Discussions
However, Unity is unable to display that data by itself. In Advanced Inspector 1.2;
Full support to display of any class implementing the IDictionary interface.
The same features existing on all other fields - copy, paste, apply, revert - also works on Dictionaries. All the IList attributes are properly past down to the Dictionary “value” field.
The “value” is also expandable and editable “inline” like on any other reference field.
I’ve added the class “Mesh” to the supported types;
However, as I implemented it, I encountered out some common issue to all property grids; large or extra large array.
When you try to sort, handle and draw hundred or thousand of items, performance can take a dive and become unusable. A mesh can have thousand vertices! Listing them can kill your editor.
So I added automatic support for large array, and since an image is worth a lot of explaining;
It makes those array a bit more manageable, and doesn’t kill your performance.
Today’s WIP update; preview with ease;
This is - again - done without any custom editor!
Here’s the code of that class;
[AdvancedInspector]
public class AIExample_Preview : MonoBehaviour, IPreview
{
[Inspect]
public bool showPreview = true;
[Inspect]
public GameObject previewGO;
#region IPreview Implementation
public bool HasPreview
{
get { return showPreview; }
}
public UnityEngine.Object[] Preview
{
get { return new UnityEngine.Object[] { previewGO }; }
}
#endregion
}
Implementing the IPreview interface can’t be easier; you just return the objects you want previewed.
When released, the Advanced Inspector will support types of GameObject, Mesh, Material and Texture.
The HasPreview property allow to turn the preview on and off.
Small update on the preview panel;
Can support multiple object being previewed at the same time from the same script. Support currently GameObject/Prefab, Mesh, Material and Texture.
Added a third light setting to the preview to give a better sense of depth; a Red/Green/Blue light setup.
(Why do I have the feeling I’m talking to myself here…)
1 Like
We discovered there’s a GUI that is used to display a range between two value, but Unity does not offer any type that take advantage of this. At least, none we could find.
So we made some.
Again, done in the most painless integration possible;
[AdvancedInspector]
public class AIExample_Range : MonoBehaviour
{
[Inspect, RangeValue(0, 100)]
public RangeInt rangeInt = new RangeInt(25, 75);
[Inspect, RangeValue(0, 100)]
public RangeFloat rangeFloat = new RangeFloat(25, 75);
}
When using this in 4.5, the RangeInt and RangeFloat are structs, while in previous Unity version, they are classes.
While 1.2 is in validation, we noticed we forgot to support one obvious type in the Preview window; Cubemap.
Might do a 1.21 version with that missing type support.
We received feedback that the Advanced Inspector was hard to read in the context of multiple object/multiple nested level. (Big thanks to “_brain” for his ideas)
You can see some of the above images and see what that means.
We were proposed that we should find some way to “box” the nested context, so to be able to structure the values more properly.
Here’s what we are going towards;
We hope this way will make nested context much easier to read.
Version 1.3 will be more of a visual/layout update more than anything else. We fixed ton of layout/alignment issue.
One request we got was to be able to dump the “[class name]” part of the field of an expandable item.
So it looks like this;
The “4” showing up there is taken from the ToString overriden method.
public override string ToString()
{
return value.ToString();
}
You can write whatever you want on that label.
We are also working on a Header/Footer zone at the top and bottom of the inspector. We already had a header for the tabs, but we decided to add more to it, such as element independent from fields;
Help attribute can now be tagged on a class, and shows up before or after all the fields in a header/footer zone.
The header and footer are accessible by using the IInspectorRunning interface, which expose “OnHeaderGUI” and “OnFooterGUI”. So in the above image, the “This is a header” and “This is a footer” is actually drawn from the script itself using GUILayout.Label.
So you could draw image, control or anything you wish in those top and bottom zone, once again, without a custom editor.
The Light editor was surprisingly difficult to replicate because 2 of the values displayed on the default Inspector are not exposed in the backing type. What it means is, if you look at the Light type, you won’t find a “Draw Halo” or “Lightmapping” properties. For this reason, it meant the InspectorField had to be rewritten in part to be able to wrap around SerializedProperty; the only way to reach those hidden values. Let’s just say I’m really not a fan of that particular class.
Another reason that specific editor have been challenging to recreate is the number of variable that can be hidden and the number of warnings that can be displayed.
But even then, if you can look at LightEditor.cs in UnityEditor assembly, the class takes 340 lines. The AdvancedInspector version, who perform exactly the same job - while giving more features than the stock version - takes only 202 lines,.
1 Like
Because there is no such thing as being too lazy;
Drag and drop of labels perform automatic copy/paste.
The version 1.32 have been submitted for review to the Asset Store, with the “object picker”;
Frankly, I’m starting to run out of idea. I would be happy if someone had some.
One feature that was requested was the ability to color the background;
And another was to be able to only display 1 item from a collection at a time, which in return eliminates one level of indentation.
This is a list;
The next version will finally be 1.4 instead of 1.33, since it has some major definition changes in some attributes. Here’s others that have been requested…
Here’s an example;
Every atttribute controlling enums are merge into a single attribute. Same thing with attributes handling collection.
The EnumAttribute, CollectionAttribute and RestrictAttribute now have each a Display enum to control how the item is being displayed.
Enum currently can be displayed as a drop down list, a collection of button or a collection of checkboxes.
Restricted item can be displayed as drop down, botton or toolbox invoke.
Collection can be displayed as their default behaviour - expandable list, as a drop down list or as button. Note that when collection displays only one item at a time, copy/paste feature of that index/key becomes impossible.
Dictionary doesn’t currently support different display type because of the fact it has to render a complete field for adding items.
Tiny feature; draggable modal window.
This feature is rather simple; it binds a collection to the values of an enum.
It makes more sense when we look at the code example;
[Inspect, Collection(typeof(CollectionName)), RangeValue(0, 10)]
public float[] range;
public enum CollectionName
{
First,
Second,
Third,
Forth
}
1 Like