Search code examples
unity-game-enginecanvastransformscalegameobject

How to scale two game objects with different scale sizes proportionally?


I have two game objects, one for main canvas and other for editor (a dummy version).

The scale for main go is 1, 1, 1 and other one (dummy) is .3, .3, .3. What I want to do is scale the main gameobject proportionally based on the scale percent that the user sets to dummy go, how I can do this?


Solution

  • DummyGameObject.transform.localScale = CanvasGameObject.transform.localScale * 0.33f; //or
    DummyGameObject.transform.localScale = CanvasGameObject.transform.localScale / 3;