- Home /
LocalScale and uv
soooo... i have cube with adjusted uv mapping. I need to scale it by script. I change it by transform.localScale. and then custom mapping goes away.
When i apply scale 1st and then custom uv - no changes, its the same. But if i change scale by inspector, everything work as expected.
i check everything, only one way is to change it by "hands".
question is - how to fix it?\what command i have to use to access scale directly?
edit1: Looks like i found where is problem. When i apply localScale (no matter before or after uv editing) uv coordinates, that read by raycast goes to stock values, but actually texture mapping saved perfectly.
its still issue lol. "How to read "right" uv positions after applying localScale?"
I have no idea what you're talking about. The scaling of the transform only affects the attached renderer and how the mesh is drawn. The UV-map of the mesh isn't changed at all. Every vertex of the mesh have it's UV coordinate and they stay the same, no matter what you do with the transform.
What do you mean by custom uv after you scaled the object? Unity can't edit the unwrap unless you've written an UV editor for Unity.
Please try to explain your problem a bit more in detail and maybe provide a screenshot.
PS. Don't post an answer to provide this information. You should edit your question. Answers have to answer the question. Use a comment if you want to reply to my comment.
Yep, a picture would be easier to understand than "goes crazy".
To edit question, click EDIT button below your question.
To format code, select it and click the 191-010 button above where you type your question.
Are you sure you use a $$anonymous$$eshCollider? The UV coordinates returned by a Raycast are from the collider you hit, not the mesh. Only a $$anonymous$$eshCollider (with the same mesh) would return the correct UVs.
"Only a $$anonymous$$eshCollider (with the same mesh) would return the correct UVs."
good point, i thought about it while coffee brake.
Answer by DEtH_MoroZ · Aug 18, 2011 at 02:29 PM
"Only a MeshCollider (with the same mesh) would return the correct UVs." yes, that was right.
so, if you are manage to mess with custom, runtime generated UVs, and if u want to draw on it - make sure that mesh with new UVs applied to mesh collider, or new UVs will disappear when u will use corresponded gameobject's transform.
tyvm everyone, i really appreciate that.
Your answer
Follow this Question
Related Questions
How is localScale adjusted when re-parenting transforms? 2 Answers
How to make an object's localscale values grow and shrink within a few seconds? 0 Answers
Rescaling goes wrong? 0 Answers
Attempting to Calculate and Change Scale of Platforms Sets Scale to 0 1 Answer
Warning: "Setting scale failed, ignoring request." ? 1 Answer