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

Correct duplication of GameObjects #61

Closed
JamesTKhan opened this issue Jun 8, 2022 · 1 comment
Closed

Correct duplication of GameObjects #61

JamesTKhan opened this issue Jun 8, 2022 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@JamesTKhan
Copy link
Owner

When you duplicate a GameObject in the editor, each component is cloned in GameObject.java

        this.components = new Array<Component>();
        for (Component c : gameObject.components) {
            this.components.add(c.clone(this));
        }

However, some components do not have cloning implemented due to technical limitations or just not being implemented yet, like terrain component

    @Override
    public Component clone(GameObject go) {
        // Cant be cloned right now
        return null;
    }

When duplicating a GameObject with components that cannot be cloned the editor crashes as a null component gets created and a NPE happens. We should add logic to handle when a null component is returned, either stop cloning the game object, or clone it partially without the components that could not be cloned. Adding a UI dialog in the editor would be a nice addition as well to notify when this happens.

@JamesTKhan
Copy link
Owner Author

Closing this out as I have disabled the duplication button for Terrain and Water components in UI, as well as throwing an exception on cloning of Water or Terrain as cloning them is not supported.

@JamesTKhan JamesTKhan removed this from the 0.5.0 Release milestone Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant