title: Scale ingame color picker
body: <p><strong>Hey,</strong></p>
  
  <p>I am working on a 3D room editor where you can grab an object from a menu and put it back in a room. You also get the option to give these objects a different color, this is done by the color picker. I now have a script that works the way I want it only if I enlarge the color picker, then he does not pick up the colors anymore and he does not move the selector circle anymore.</p>
  
  <p>How do I solve this?</p>
  
  <p><a href="https://i.stack.imgur.com/jxSro.gif" rel="nofollow noreferrer">GIF Color picker at 1.8 scale</a></p>
  
  <p><a href="https://i.stack.imgur.com/aTg7Y.gif" rel="nofollow noreferrer">GIF Color picker at above 2 scale</a></p>
  
  <p><strong>Color picker script:</strong></p>
  
  <pre><code>Color[] Data;
  SpriteRenderer SpriteRenderer;
  
  GameObject ColorPicker;
  GameObject Selector;
  BoxCollider Collider;
  public GameObject target;
  Ray rayray;
  private Plane MyPlane;
  
  public int Width { get { return SpriteRenderer.sprite.texture.width; } }
  public int Height { get { return SpriteRenderer.sprite.texture.height; } }
  
  public Color Color;
  
  void Awake()
  {
  
      ColorPicker = transform.Find("ColorPicker").gameObject;
      SpriteRenderer = ColorPicker.GetComponent&lt;SpriteRenderer&gt;();
      Selector = transform.Find("Selector").gameObject;
      Collider = ColorPicker.GetComponent&lt;BoxCollider&gt;();
  
      Data = SpriteRenderer.sprite.texture.GetPixels();
  
      Color = Color.white;
  
      Debug.Log(Collider);
      MyPlane = new Plane(transform.TransformDirection(Vector3.forward), transform.position);
  }
  
  
  void Update()
  {
  
      if (Input.GetMouseButton(0))
      {
          rayray = Camera.main.ScreenPointToRay(Input.mousePosition);
          MyPlane = new Plane(transform.TransformDirection(Vector3.forward), transform.position);
  
          Vector3 screenPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
          screenPos = new Vector3(screenPos.x, screenPos.y);
  
  
          //check if we clicked this picker control
          RaycastHit[] ray = Physics.RaycastAll(rayray.origin, rayray.direction);
          foreach (RaycastHit h in ray)
          {
              Debug.Log(h.collider.name);
              if (h.collider.name == "ColorPicker")
              {
                  Selector.transform.position = screenPos;
  
                  //get color data
                  screenPos -= ColorPicker.transform.position;
                  int x = (int)(screenPos.x * Width);
                  int y = (int)(screenPos.y * Height) + Height;
  
                  if (x &gt; 0 &amp;&amp; x &lt; Width &amp;&amp; y &gt; 0 &amp;&amp; y &lt; Height)
                  {
                      Color = Data[y * Width + x];
                      target.GetComponent&lt;Renderer&gt;().material.color = Color;
                      Debug.Log(Width);
                      Debug.Log(Height);
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p><strong>GIF</strong></p>
  
  <p><a href="https://i.stack.imgur.com/FEXEP.gif" rel="nofollow noreferrer">This is the inspector from the color picker color field</a></p>
  
  <p><a href="https://i.stack.imgur.com/Im9Ck.gif" rel="nofollow noreferrer">This is the inspector from the main camera</a></p>
  
  <p><strong>IMAGE:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/A6coP.png" rel="nofollow noreferrer">This is the inspector from the color picker color field</a></p>
  
  <p><a href="https://i.stack.imgur.com/vn4o5.png" rel="nofollow noreferrer">This is the inspector from the main camera</a></p>