0 Favourites

How do I Copy a layout but have new UIDs per object?

  • Hi

    I have read this thread : and searched avidly on this forum for an answer but I have struggled to find what I am after.

    Basically I need to copy/clone the structure of a layout from one scene to another but when I do this with duplicate or copy and paste, the UIDs of the original objects remain the same for the newly copied objects which means that when I change the object name on the newly copied version, it renames the object name on the existing version.

    Is there an easy way of doing this or would I have to keep adding and layouting the same structure on the new layout ?

  • Right click the layout in the project three, choose duplicate.

  • UIDs should not be duplicated - they should be unique per instance within the same project. You should probably file a bug if you're seeing one project with the same UID used twice.

  • 99Instances2Go that is what I have tried and the UIDs remain the same on both layouts

    Ashley Ok thanks for this

  • Just tested this on r241 and UIDs are definitely unique and not duplicated on new Layout.

    Would it be possible to show us an example .capx where this is happening?

  • zenox98 I will upload a capx file for this, however the release you have is this just a testing release and not a public release ?

    ** EDIT **

    Now I feel embrassed as I have tried to re-create this on this release and cannot I know it was definatley happening because everytime I change the object name on the new layout, it kept changing it on the original and the UIDs were the same aarrrrrrghhhh.

    Sorry to waste everyones time

  • I think I have found the issue, it is when you rename the object on the new layout after it has been copied. I am going to test this on a new project to see if it happens then. It appears fine when the layout has been copied but as soon as I renamed the new object to something else it seems to change the same object on the original layout as well and then they both have the same UID

  • Yep created a new project copied the layout 1 to layout 2 and the objects are not newly created for layout 2 so when I then rename the e.g. "text" object on the new layout (layout 2) it renames the object on the original layout as well.

  • It takes a few seconds for 'it' to update the property text for UID. Why, i dont know. Give it a few seconds, and you will see that they have definitely different UID's.

    The name changing in both layouts is normal eh. Confusing remark.

  • 99Instances2Go My problem here is that I need the objects to be separate as if I refer to the object by its name would this not conflict ? The idea being is to make a complete clone of the original layout and have it clone all of its objects as well .

    Does this mean I would have to re-create the second layout manually ?

  • If you want to refer by its name, you need a clone.

    But. Why would you do that ? Refer by an instance variable.

    If you want to refer by name, the amount of events will outrun your live, you will have to re code each event sheet too.

  • 99Instances2Go

    How do I clone objects from one layout to a new one ? secondly the goal here is to create a "template" of an original layout and use its design with others. So these layouts are menus , they will all look alike apart from the Menu title,button/sprite labels and what actions are trigged when they are touched/clicked on.

    As this is the case, I was trying to simplify the creation of the layouts to speed up creating my project .

    I am not sure what you mean by refer to it as an instance variable, it could be that I was not clear with my goal on what I am trying to do so sorry if I have mislead you on this.

    The project is mearly for my personal use as I am learning a spoken language and felt that if I put what I am learning into an app/game format it will help me with my progress .

  • I dont know how to easy clone a complete layout. Maybe by 'hacking' the layout XML's. Might be a case of 'search and replace'. But that is totally out of my league.

    Your goal is always producing a code, events, a script, how ever you wanna call it. Excuse me for anticipating on what follows on the cloning.

    In my humble eyes is a copy of a layout, and reusing a lot of the code preferable above a clone of the layout and having to recode everything.

    If you gonna make templates, my opinion is that you should use families and families only. That way you can very easy replace objects and keep kinda everything in place.

    Menu's are a lot easyer to do with 1 Global Layer, another tip.

    But hey, i might be wrong, and wayyyyyyyyyyyyyyy of a topic that started with UID's.

  • 99Instances2Go Thanks for your input I have currently decided to take the only route I know for now to get this project up and running, if I had more time to work out the methods you have kindly mentioned here I would. The reason for the deadline is that I need to get this self teaching working fast so that I can focus on learning something else as well!

    Construct 2 has been a great game maker for me as I have tried many other game makers and found this to be the best.

    Oh and I do not think you went that off topic my originaly post was based on trying to get a copied layout to work on its own.

    Thanks again 99Instances2Go for your help

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • When you duplicate a layout, you are making copies of the instances of object types that are present in that layout.

    So it is natural that renaming an instance of the object type in the duplicated layout ends up renaming the object type in the original layout since it is a single object type all along.

    And referring to the name of instances in the event sheet is all fine and one of the strengths of Construct 2.

    When using an event sheet applied to a layout, the events only apply to the instances of that layout.

    The interest of duplicating layout is to be able to use a common event sheet.

    Generally, you will have a "Common" event sheet containing mechanics that are common to all your layouts.

    For example, clicking on a button and possibly having a callBack from there.

    Then, specific event sheet for each layout will be created (containing the specific callBack for each layout) and including the common event sheet.

    At last r241 is a beta release the link of which can be found at the bottom of any page of the website and in this page.

    See this example made in r241.

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