Properly scale the placed element's material
This commit is contained in:
1 parent
16a9f846af
commit
84f6a7d690
2 files changed
+6
-2
No files matched your search
@@ -27,6 +27,12 @@ public class SimpleResizer
|
||||
prefab.transform.localPosition = Vector3.zero;
|
||||
prefab.transform.localRotation = Quaternion.identity;
|
||||
|
||||
// Marc Scale fix
|
||||
// Calculate the texture scale based on the ratio of new size to default size
|
||||
Vector2 textureScale = new Vector2(newSize.x / resizable.DefaultSize.x, newSize.y / resizable.DefaultSize.y);
|
||||
prefab.GetComponent<Renderer>().material.mainTextureScale = textureScale;
|
||||
|
||||
|
||||
// cleanup
|
||||
MonoBehaviour.Destroy(resizable);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user