Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

Internally serialized info on duplicate

So recently I had to work with components that automatically serialize id-like data (similar to lineID or constantID). And one of the issues I encountered was how to clear that data when item is copied or duplicated. The solution I eventually came up with was:

private bool freshlyInitialized = true;
private void OnValidate () //Unity Event
{
            Event e = Event.current;
            if (e != null && !string.IsNullOrEmpty(e.commandName))
            {
                // freshlyInitialized is used to avoid false flags when pasting values into component fields
                bool componentPaste = (e.commandName == "Paste" && freshlyInitialized);

                if (e.commandName == "Duplicate" || componentPaste)
                {
                    ActionsOnCopyOrDuplicate();
                }
            }
            freshlyInitialized = false;
}

Now I was wondering whether this is/could be handled in AC, since for example duplicating Hotspots is a thing I do pretty commonly. And after duplication lineID is retained (at least editor shows it this way). And when those hotspots have lineID, the next text gather while giving each one of them an unique ID has a small chance to link the existing translation to one of the copied/duplicated hotspots instead of the original one. Also are there other places where I should look out for risks with duplication?

Comments

  • edited August 2018
    Hotspot names, NPC names and Conversation dialogue option labels would be the three to look out for.

    "freshlyInitialized" wouldn't be serialized though, so I'm not sure that's the safest approach.  It's also not going to trigger when a component is copy/pasted within the GameObject itself - unfortunately, Unity seems to be lacking a "clean" way to approach this.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!