Hello!
So, my speedo works and it works well … in only one aspect ratio / resolution. When I try to change res or ratio, things get really nasty!
I was thinking that hack no.1 would be to hard-code position and scale per resolution, so easssentially have a bunch of settings for every resolution I can think of. That’s pretty ikky.
I’d love to solve this properly, but the whole matrix thing is beyond my tiny mind and I just don’t see how I can … if you can help, I’d be super-grateful!
I’m using the (mighty!) Duck’s code from UnityAnswers … note this is the base code and I’ve taken out any failed attempts at making it scale!
ANY ideas on making a speedo needle rotate nicely in different resolutions would be REALLY welcome
using UnityEngine;
[ExecuteInEditMode()]
public class drawSpeedo : MonoBehaviour {
public Texture2D speedoTexture = null;
public Texture2D texture = null;
public float angle = 0;
private Rect sRect;
private Vector2 pivot;
void OnGUI() {
GUI.DrawTexture(new Rect(Screen.width/2+165,Screen.height-144,128,128), speedoTexture);
Matrix4x4 matrixBackup = GUI.matrix;
Vector2 pos1 = new Vector2(Screen.width/2+173+64,Screen.height-134+64);
GUIUtility.RotateAroundPivot(angle-95, pos1);
sRect = new Rect(Screen.width/2+173,Screen.height-134,128,128);
GUI.depth = -6;
GUI.DrawTexture(sRect, texture);
GUI.matrix = matrixBackup;
}
}