mjholtzem / Unity-2D-Destruction

MIT License
622 stars 98 forks source link

Odd sprite generation - not following marked areas #7

Open Haddicus opened 6 years ago

Haddicus commented 6 years ago

Was hoping to get this working, but the segmentation's seem not to be aligning properly with my sprites. I thought it was an issue with using a spritesheet, but have the same result when generating from an individual sprite.

Fragments Generated in editor: image

Generated segments: image

Not sure what's going on here, or if this is just broken in 2018.1.1f1

Haddicus commented 6 years ago

stool Here's the sprite I'm trying to use for the test.

clonzeh commented 5 years ago

i'm noticing this problem when a parent gameobject has different scale.

clonzeh commented 5 years ago

update to this: I have found some issues. (Same applies to Triangle methods) inside GenerateVoronoiPieces 1) store the originalscale local scale in a separate vector3, set the origScale = the source.lossyscale at the bottom of the same method, set the source localscale to 1) inside GenerateVoronoiPieces set the piece localscale to the source lossyscale inside calcUV

change the textHeight and texWidth to divide by losscale instead of localscale.

Lastly, inside: the getRect(GameObject source) method, set the return to: return new Rect(sr.bounds.extents.x -1, sr.bounds.extents.y -1, sr.bounds.size.x 2, sr.bounds.size.y 2);

if that doesnt fix it also set change it from Renderer to SpriteRenderer