Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default instance inconsistent between run and edit time #8352

Closed
F3der1co opened this issue Dec 9, 2024 · 6 comments
Closed

default instance inconsistent between run and edit time #8352

F3der1co opened this issue Dec 9, 2024 · 6 comments
Assignees
Milestone

Comments

@F3der1co
Copy link

F3der1co commented Dec 9, 2024

Problem description

The default instance is different between edit and runtime. These should be unified to be less confusing. Also the way the default instance is selected at runtime is better as it gives us more control (being the first instance on the first layout in layout order defined by the project bar).

Attach a .c3p

defaultInstance.zip

Steps to reproduce

  1. drag a new tilemap instance into the layout from the project bar
  2. note which tilemap it was spawned with
  3. run "layoutToTest"
  4. see which tilemap was spawned

Observed result

default instances are different between edit and runtime

Expected result

the default instance is the same (runtime default instance is the expected one for both cases)

More details

Affected browsers/platforms:

First affected release:

System details

View details

PASTE HERE

@F3der1co F3der1co changed the title creating instance at edit time picks wrong default instance default instance inconsistent between run and edit time Dec 9, 2024
@Jase0000
Copy link

Jase0000 commented Dec 10, 2024

I know this has been a long-time issue, but now we have templates, perhaps we could have option for objects to define a "default template", so whenever an object is dragged onto a layout, or created at runtime with blank "template" param, it can pull from the chosen "default template", thus solving this once and for all? This wouldn't affect old projects since older projects haven't defined the default template, and solves it for anyone that wishes to choose a default.

Still means we must setup a template to define a default, but that's absolutely fine to do imo!

EDIT: I guess theres issues with this idea, such as changing the default template and what it should do to all objects already in a layout, but yeah just spitballing ideas.

@AshleyScirra
Copy link
Member

If I drag the tilemap in from the Project Bar in r419, it creates a tilemap with a number 3 drawn on it. If I preview 'layoutToTest', it looks like it creates an instance of a tilemap with a number 3 drawn on it. So it looks like it is consistent to me. Note your "observed result" doesn't actually describe what you see, only that it's different. Am I missing something?

@F3der1co
Copy link
Author

interesting, I also cannot reproduce this anymore. Maybe there is something tied to the current session. But Tokinsom on the suggestion referenced above described the same issue, so I am certain this issue exists.
I'll investigate further

@F3der1co
Copy link
Author

F3der1co commented Dec 10, 2024

@AshleyScirra ok, so I can reproduce the issue when I make a new project, but if I save, close c3, open the project again it works as expected.
This makes creating a repro c3p difficult.

repro.mp4

@kingpirux
Copy link

Oh i know this problem is very old actually, i know it from Construct2 lol. But is like something all users have mentally blocked because we know it happens and is very rare to reproduce.

Basically the problem is the default instance will be the first in memory :P so is not easy to reproduce, and is not consistent until you save and reload the first time.

When you save and re open the system take as Default the first instance in the first layout, the same as when running project entirely.
BUT first run, without saving, some times, the default will be the first instance in the LAST layout you opened, and sometimes if you create and erase, it will still take as default the deleted one, thats why i already have like pre defined instances in an "assets" layout and i put everything there as i want it to be spawn, and this layout MUST BE always first on top of the list of layouts, even higher than loadder layout.

@AshleyScirra
Copy link
Member

So this was a bit of a tricky one but I think it's fixed for the next release cycle (first beta after next stable release). The runtime finds its first instance by looking at the first layer on the first layout it is placed on, whereas the editor uses the first added or loaded, which isn't always the same. With the fix the editor uses the same order as the runtime and looks through layouts and layers in order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants