Skip to content

Feat: Restore re-orderable lists and add reordable arrays in GameStudio#3067

Draft
Acissathar wants to merge 3 commits intostride3d:masterfrom
Acissathar:feat-Restore-reorderable-lists-in-gamestudio
Draft

Feat: Restore re-orderable lists and add reordable arrays in GameStudio#3067
Acissathar wants to merge 3 commits intostride3d:masterfrom
Acissathar:feat-Restore-reorderable-lists-in-gamestudio

Conversation

@Acissathar
Copy link
Contributor

PR Details

Restore re-orderable list functionality in the GameStudio editor, along with adding support for Arrays and restrict dictionaries. Most of this code was already present in the engine, it was just commented out with "FIXME" without any info on what was broken.

Through local testing, the issue seemed to really just be that the re-ordering was attached to the Parent rather than the actual items of the list. This was a minor tweak, and supporting arrays just needed a small helper to store the indexes we're looking to swap.

Dictionaries I think are out of the scope of this PR, as I believe the Quantum system will need a decent amount of changes to account for needing to store a positional reference.

Related Issue

#3065

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.

In order to have an array or list be re-ordable, it needs the [MemberCollection(CanReorderItems = true)] attribute.

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Acissathar
Copy link
Contributor Author

Acissathar commented Feb 12, 2026

Draft because I haven't really put it through any wringers, just a super basic test.

Test script:

public class ReorderTest : ScriptComponent
{
    // Can re-order
    [MemberCollection(CanReorderItems = true)]
    public List<int> Items { get; set; } = new List<int>();

    // Cannot re-order
    public List<int> NonReorderableItems { get; set; } = new List<int>();

    // Can re-order
    [MemberCollection(CanReorderItems = true)]
    public int[] ItemsArray { get; set; } = new int[4];

    // Cannot re-order
    [MemberCollection(CanReorderItems = true)]
    public Dictionary<int, int> AnotherItemDictionary { get; set; } = new Dictionary<int, int>();

    // Cannot re-order
    [MemberCollection(CanReorderItems = true)]
    public int SingleItem { get; set; }
}

And GameStudiobehaivor:

ReorderTest

@Acissathar
Copy link
Contributor Author

Per the linked issue, I tested Undo/Redo and Archetypes as mentioned by @Kryptos-FR as potential issues with reorderable collections in the past.

Undo/Redo applies to the list element and changes done to the elements (in order of operation):

ListUndoRedo

Archetypes I don't have much practical experience with, just a general overview and assumption on how it works based on experience in Unity:

Re-ordering the derived / child asset seems to work as expected without messing with the archetype / parent:

Base Material:
image

Derived Asset changing order:
image

However, changing it on the parent / archetype asset when the child has their own changes, does cause an issue and duplicates elements rather than shifting the order:

image

I suppose the question then becomes, what should it do? If the Archetype has Layers 0, 1, and 2 and on the Derived asset we swap layers 1 and 2 (0 - 2 - 1), then go on the Archetype and swap 0 and 1 (1 - 0 - 2), what should be reflected? With prefabs, we leave overridden child changes alone when changing the base/parent, but since we're swapping elements, I don't think that really works here because then we'd copy the unchanged layer (0) but since 1 was already moved, we'd have (1 - 2 -1) which seems wrong too.

Maybe if any elements are re-ordered in the given section, we ignore any changes on the Archetype on the derived asset?

I'll be gone this weekend for a trip so won't be able to take a stab at the archetypes part for a bit, so keeping it in a draft, but wanted to leave some more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants