ATF Level Editor and PropertyEditor drag & drop

100 views
Skip to first unread message

Pierre Blanc

unread,
Jan 20, 2016, 6:36:13 AM1/20/16
to Authoring Tools Framework
Hi there,

I'm currently working on a project which started from the LevelEditor codebase, with the goal of creating an Editor which is similar to the way of building a scene in Unity.


LevelEditor versus Unity philosophy :

In LevelEditor, the game objects are specialized to add functionalities to them. Per instance one of them is a Locator which allows to add a Model resource to the game object, another one is a DirectionLight etc...
In Unity, the philosophy is different. Game objects are generic, and can be understood solely as containers, and instead of specializing them, we add components to them in order to add functionality : A ModelRenderer component, a Camera component, etc...

The reason why we find Unity approach better is because it is very flexible and allow an infinite combination of behaviors for our game objects. But maybe this is not a debate i would like to start, but more an introduction to what we are trying to do, starting from the LevelEditor.


What we did so far

So so far we only use the GameObjectGroup, which behave like a Unity game object, a container which can contain components and allow parenting.
In the process I have created a bunch of components, for static models, skeleton animated models, camera, light, colliders, etc... And also a bunch of new tools : a camera preview, a material editor. This is working great so far, although it feels going away from the philosophy of the LevelEditor.


My questions :

Is it possible to implement drag and drop functionality in the PropertyEditor ?

Per instance I have a field in my ModelRenderer component which is using a FileUriEditor to pick up what model i want to use with this component. Or in a material collection I have a bunch of materials, each of them with a field where I can select the material filename to use for this particular model material slot. What I would like to be able to do is to be able to drag and drop my resources directly from the ResourceLister into this particular control, instead of having to click on the [...] button to select a filename.
Could someone please point me in the direction to be able to implement such functionality ? 
I thought about few ways but I'm not too sure what is possible, still quite confused about ATF. 
- Is it possible to have a tree editor inside the PropertyGrid (that may be a solution to implement drag and drop on collections but maybe not ideal)?
- Is it possible to have the FileUriEditor accepting Drag&Drop and raising corresponding events ?

Thanks for reading, and the hard work on ATF and the LevelEditor!

Pierre



Ron AtSony

unread,
Jan 21, 2016, 6:26:20 PM1/21/16
to Pierre Blanc, Authoring Tools Framework
Hi Pierre,

I work at Pocket Gems in San Francisco (we're hiring!) and I happened to work on this problem recently with our version of LevelEditor. Previously, I worked at Sony and I was the lead programmer on Authoring Tools Framework for many years.

The trick with drag-and-drop functionality in the PropertyEditor is that you need a property editing control that can accept drag-and-drops. I created DomNodeDragDropEditor that implements IPropertyEditor and that can provide a property editing control with drag-and-drop functionality. Please see the attached file. I have permission to contribute this back into the open sourced LevelEditor, so you can consider it to be open source under the Apache 2.0 license. Here are the comments about it:

    /// <summary>
    /// A property editor (that can be used in a PropertyDescriptor) that provides a universal
    /// property editing control (PropertyEditingControl) that accepts dragging and dropping
    /// of DomNodes or DomNodeAdapters. Use a TypeConverter like ReferenceDomNodeTypeConverter
    /// to convert a DomNode value to a string.</summary>
    /// <typeparam name="T">A DomNodeAdapter type that a dragged DomNode or other DomNodeAdapter
    /// can be adapted to using ATF's adaptability As and Cast extension methods.</typeparam>
    /// <remarks>To use this in a schema file annotation, the syntax goes like this:
    /// editor="LevelEditor.Controls.PropertyEditing.DomNodeDragDropEditor`1[[LevelEditor.DomNodeAdapters.Material, LevelEditor]], LevelEditor"
    /// </remarks>

If you replace your FileUriEditor with DomNodeDragDropEditor, I think you will have the behavior you are looking for. Here is the schema annotation that is used with a "Material" property that is a file name. The user can drag-and-drop a Material DomNodeAdapter from a separate editor (Material Lister in our case) to the Material property in PropertyEditor. That strange notation with `1 is how .NET displays the type name of a type that takes a generic parameter.
        <scea.dom.editors.attribute name="material" displayName="Material" converter="LevelEditor.Controls.PropertyEditing.ReferenceDomNodeTypeConverter,LevelEditor" editor="LevelEditor.Controls.PropertyEditing.DomNodeDragDropEditor`1[[LevelEditor.DomNodeAdapters.Material, LevelEditor]], LevelEditor"/>

I don't see any way of making FileUriEditor accept drag-and-drop events, because it doesn't expose its editing Control, and so there is no way to override OnDragEnter, OnDragOver, OnDragDrop, and OnDragLeave, or to listen to the corresponding events.

Good luck!

--Ron



--
You received this message because you are subscribed to the Google Groups "Authoring Tools Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to authoring-tools-fr...@googlegroups.com.
Visit this group at https://groups.google.com/group/authoring-tools-framework.
For more options, visit https://groups.google.com/d/optout.

DomNodeDragDropEditor.cs

Pierre Blanc

unread,
Jan 30, 2016, 6:27:46 PM1/30/16
to Authoring Tools Framework, pierre...@gmail.com
Hi Ron,

This answer beats a record of late reply, sorry about that..

Your code and precise reply helped me a lot to implement the functionality I needed. In the end I went for a similar solution but with a ResourceDragAndDropEditor, code attached. It seems to work perfectly so far.
I'm working remotely for Marmalade Game Studio in London, building an internal tool to edit game levels.
I don't have a lot of experience with c# and ATF is quite complex so i'm struggling a bit but we will get there!

Thanks a lot for your help.
Pierre
To unsubscribe from this group and stop receiving emails from it, send an email to authoring-tools-framework+unsub...@googlegroups.com.
ResourceDragDropEditor.cs
Reply all
Reply to author
Forward
0 new messages