Templates feature in r286

2 favourites
From the Asset Store
Fruit Slicer Template & Quality fruit and slice graphics (c3p,png,illustrator files)
  • Introduction

    This new feature comes in to address a few rather old issues with Construct, which are the following:

    1. Updating several instances of the same object type with different initialization properties could prove to be time consuming and prone to error. Specially in large layouts or across multiple layouts.
    2. No way to define pre-sets when creating an instance at runtime using the Create Object action. Up until now you had to create the instance and then set it's properties in the event sheet.
    3. No way to choose a specific hierarchy to create at runtime, if multiple were created in the editor using the same type of instance as the root. This forced you to use unique instances as roots in order to guarantee the hierarchy that would be created at runtime.

    Granted those three issues could be worked around, from now on you won't have too anymore.

    New terms

    There are two new terms that will be used in this guide.

    1. Template: an instance that has been set to be the source of property values for other instances to use. These include, common instance properties, plugin properties, instance variables, behaviour properties and effect parameters. A template can also be used to decide what values a new instance created at runtime should take when using the Create Object action. Modifying a template in the Layout view or through the Properties bar will immediately be reflected in all instances which are replicas of it.
    2. Replica: an instance that has been set to use an instance already defined as a template. A replica takes it's values from the source template unless they are explicitly modified, at which point the replica's own values are used.

    How does it work?

    The Properties bar now shows a few new properties when selecting an instance.

    Properties bar Property descriptions
    • Template mode: an instance can be turned into a template by selecting the "Template" value from the drop down menu. If there are any instances in the object type which have already been set to be a template, then the "Replica" value will also be available in the drop down menu.
    • Template name: the name to identify a template. This input is only active when Template mode equals to "Template".
    • Template source: the name of the template a replica is using. Only shows templates of the same object type as the replica. The drop down is only active when Template mode equals to "Replica".

    To start using this feature the first thing you will need to do is set an instance to be a template. To do that, follow these steps:

    1. Select the instance you want to be a template in the Layout view.
    2. Pick the "Template" option from the Template mode dropdown in the Properties bar.
    3. Give the template a name using the Template name text input.

    That's all you need to do to set an instance to be a template.

    Now let's see how to set other instances to use the template in the editor:

    1. Select the instance you want to be a replica of the template in the Layout View. The instance must be of the same object type as the template.
    2. Pick the "Replica" option from the Template mode dropdown.
    3. Select the template the replica instance should use from the Template source dropdown.

    After doing that you will notice that some of the properties in the Properties bar are highlighted, this indicates that the instance is taking that value from the source template.

    From now on, when the template is modified, all replicas using it, will reflect the changes. If a replica is modified individually, the affected property will stop taking the value from the template and instead will take the value from the replica itself. To indicate this, the property will no longer be highlighted.

    Miscellaneous options

    Layout view context menu options

    Template context menu Replica context menu
    • Template instance context menu options:
      • Apply template to all replicas: force all replicas using this template to use the values of the template.
      • Select all replicas in layout
      • Open all layouts with replicas: opens all layouts with replicas of the selected template.
    • Replica instance context menu options:
      • Use all values from template: forces the selected replica to use the values from the template.
      • Select all replicas in layout
      • Open template layout: open the layout containing the template the selected replica is using.

    Properties bar context menu options

    When a replica's property is modified and because of that it starts using it's own value, it is possible to individually set it back to use the template value by right clicking on the property name in the properties bar.

    Runtime actions

    The Create Object system action now has an additional Template parameter. When specified the new instance being created will be made to be a clone of the template instance, rather than an arbitrary one.

    Asides from using the properties of the template instance, the new instance will also pick up the hierarchy from the template, if one exists. This means that it is now possible to create different hierarchies in the editor that use the same type of instance as a root, while also being able to choose which one to create at runtime.

    Considerations

    This is the first version of this feature so there are still a few things to iron out. The following are a few things which are not immediately obvious.

    • By default, replicas do not use the position properties of the template. In most cases it is more useful for these two properties to remain individual for each replica.
    • The Spawn another object action of Sprite is not yet supported.
    • At runtime, replicas are no longer connected to their templates as they are in the editor. This means that changing a template at runtime, will not affect the replicas. This applies for properties and hierarchy changes.
    • In the editor, adding or removing children from a template will not be reflected on the replicas. This could be added in the future.

    Here is an example project that can be opened in r286, showing how the feature is used.

    dropbox.com/s/ewh9h1js5ocu46a/Templates%20Example.c3p

    This is it for now. This is the first version, so there is still work to be done.

  • Wow this is a great sounding solution that has been needed for a long time, thanks for all the work put in to this!

  • "If a replica is modified individually, the affected property will stop taking the value from the template and instead will take the value from the replica itself. To indicate this, the property will no longer be highlighted."

    From a user perspective i would suggest having modified fields also have their color modified.

    I understand not wanting to have a rainbow of colors, but it this case having the color distinction instead of the regular grey should help users.

  • Great work. This is really important. Thanks

  • What a nice feature ! I am so excited it opens so much new possibilities!

    Thanks a lot Scirra team :)

  • "If a replica is modified individually, the affected property will stop taking the value from the template and instead will take the value from the replica itself. To indicate this, the property will no longer be highlighted."

    From a user perspective i would suggest having modified fields also have their color modified.

    I understand not wanting to have a rainbow of colors, but it this case having the color distinction instead of the regular grey should help users.

    Agreed, I was just about to suggest this myself. Highlighting overridden values in some way is standard in most engines and quite useful.

    The other feature I would love to see in this system is support for creating objects by name, which is something I use all the time. Perhaps there can be a "create object by template" (which takes an arbitrary template name string as an argument) action or something similar?

    All that said, templates should be a huge workflow improvement for Construct!

  • hcatarrunas

    Scoremonger

    The idea behind not highlighting is that in the case the replica is using it's own value, then nothing unusual is happening, it's just the normal behaviour.

    The UI aspect is not set in stone though, it's not like we spent a lot of time deciding how to show it :P It's mainly like that because timeline editing already is handled in a similar way. In fact, you might want to check out how it looks when you are animating a replica instance in a timeline.

    birdboy

    I have been concerned about colour blind users, and noticed that the light colours we are using for highlighting in here and in timeline editing, are probably not very useful in that regard.

    Using an icon on top of the colour change would be quite good to solve that problem.

  • This is so great, thank you! Just recently I spent several days creating a similar system using ProUI addons, and now this is supported natively in C3!

  • Th wait for 'create by template name' will be hard. :D

    That will open up a whole new world of possibilities. Insanely great feature!

  • if I right-click on the Layer field, I get an error

  • construct-static.com/images/v996/uploads/articleuploadobject/0/images/75720/templates6.png

    Dropdown list looks limited. Can we use it with text input? (Looks like Layer, X, Y) It is more useful. We can create any template with one action, using expressions or globals...

  • hcatarrunas

    Scoremonger

    The idea behind not highlighting is that in the case the replica is using it's own value, then nothing unusual is happening, it's just the normal behaviour.

    Lets say a user is having a problem with one replica (ex. going back to a project after a few months or picking up something someone else made).

    This color highlight would help to quickly see if anything is "manual" on a selection (compared to the normal grey space) and then click another replica to check, or start editing what was changed when the replica is found.

  • Dropdown list looks limited. Can we use it with text input? (Looks like Layer, X, Y) It is more useful. We can create any template with one action, using expressions or globals...

    Totally agree! I was planning to use templates to show various popup dialogues, definitely need to be able to write expressions in the template field.

  • Great work, looking forward to furthering developments already mentioned elsewhere (hierarchy most specifically.)

    Another vote here for expressions in the template field.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Amazing work!!

    Really nice addition thanks for your great work.

    I second the

    Dropdown list looks limited. Can we use it with text input

    definitely need to be able to write expressions in the template field.

    Calling by txt is a must to use the full potential

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)