I have problem - in hi-resolution and low-resolution screen Joystick touchpad in mobile is too small or too big.
I found some suggest and i’m writting easy scripts but not working:
Maybe i must put to scene 2 Third Person Controller (first for low resolution and second for hi resolution) and script must active (with children) when chech screen resolution ?
Hey i was having the same issue, found this thread and you gave me an idea of how to approach this, however there was no clear solution. In case someone in the future finds this thread “gonna” post my solution.
attach this js script on some game object (it can be the joystick prefab itself) and drag the GUI Texture (the one that is attached to the joystick prefab) into the inspector variable.
public var t:GUITexture;
function Awake()
{
var size = 0.18 * Screen.width;
t.pixelInset.width = size;
t.pixelInset.height = size;
t.pixelInset.x = size/2;
t.pixelInset.y = size/2;
}
this keeps the texture relative to the screen size. the .18 means that it will take 18% of the screen where the game is running. the setting on the inset.x and inset.y is for the texture never go off the screen, you can delete this and leave it at default 10px if you want.
A really really late reply, but i needed the exact same thing on my game.
Changing the guitexture via the normal pixelinset won’t work because the joystick script over-rides it.
Following on what przem997 said i just went and made defaultRect into public instead of private in the joystick script and just modified that through my own script depending on the needs of the device.
Works great.