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

LatticeDeformer behaves differently in edit mode compared to play mode #69

Open
msklywenn opened this issue Mar 9, 2022 · 0 comments
Open

Comments

@msklywenn
Copy link

Describe the bug
In edit mode, if a mesh is instantiated and a latticedeformer added to it, it's scale will be changed to match the size of the bounds of the mesh. Doing the same thing in play mode will keep its original scale.

To Reproduce
Make some editor script that instantiates a mesh with bounds different from (1,1,1) and adds a latticedeformer to it, and run it both in edit and play mode. Something like:

            var road = Instantiate(RoadPrefab, transform);
            var deformable = road.gameObject.AddComponent<Deform.Deformable>();
            var lattice = road.gameObject.AddComponent<Deform.LatticeDeformer>();
            deformable.AddDeformer(lattice);
            lattice.GenerateControlPoints(new Vector3Int(2, 2, 2));
            lattice.SetControlPoint(0, 0, 0, ...

Expected behavior
Scale doesn't change when script is run in edit mode.

  • OS: Windows 10
  • Unity: 2021.2.10
  • Deform version: 1.2.1

Additional context
The scale change is done when LatticeDeformer.Reset() is called by the editor. I think the problem is that this function should not be named Reset as it is one of Unity's "special functions". Renaming Reset to Reconstruct fixes the issue. I'm also not sure why Reset/Reconstruct changes the scale of the mesh, it doesn't seem needed for LatticeDeformer to work.

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

1 participant