Adam's Lair Forum

game development and casual madness
It is currently 2019/08/23, 03:23

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Custom classes editors
PostPosted: 2013/09/25, 08:51 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
How can I implement editors for custom classes used as parameters for my custom components? (i.e. Vector3 appears as 3 textboxes)

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2013/09/25, 09:30 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
This is not a trivial thing to answer. Hopefully, there will be a tutorial on this in the future, but right now you'll have to chew yourself through some example code from the editor. Here are a few directions to get you started:

  1. Set up an EditorPlugin as described here.
  2. Create a new PropertyEditor class inside that plugin. This will be the user widget. Take a look at this one for a quick example. If you need more reference, most existing PropertyEditors are defined inside the EditorBase plugin, some basic ones as well in the DualityEditor itsself and some more basic editors in the PropertyGrid dependency.
  3. Create a new PropertyEditorProvider class that delivers the appropriate editor when needed. To override the choice of an existing provider, simply return a higher priority.
  4. In your EditorPlugins LoadPlugin method, register your provider:
    Code:
    // Register PropertyEditor provider
    CorePluginRegistry.RegisterPropertyEditorProvider(new YourPropertyEditorProvider());

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2013/09/25, 11:50 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
Thanks, I think I will save it for later then :mrgreen:
On a slightly related note.. is it possible to know if a component is being drawn in the editor or in the launcher? I'd like to draw some guidelines for my more "randomic" components just to know where they are in the scene

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2013/09/25, 12:11 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
Check if the DualityApp.ExecContext Property is set to Game or Editor to provide different behavior for editing and playtesting (in the Sandbox or the DualityLauncher). Check the DualityApp.ExecEnvironment Property to determine whether the engine is run from the editor or the launcher, regardless of its current state.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2013/09/25, 12:40 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
Looking good, thanks

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group