// Use this for initialization void Awake() { if (Application.isMobilePlatform && AspectRatio.GetAspectRatio(Screen.width, Screen.height) != new Vector2(16, 9)) { Destroy(gameObject); // just destroy it god dammit screw this } }
//aspect ratioyu telefona göre ayarlar. private void FixAspectRatio() { _aspectRat = AspectRatio.GetAspectRatio(Screen.width, Screen.height, true); //Debug.Log("x " + (int) _aspectRat.x+ " y " + (int) _aspectRat.y); x = _aspectRat.x; y = _aspectRat.y; }
public void Awake() { gameEnd = false; stopped = true; textToggle = true; _remastered = DebugManager.remastered; lastCostume = null; var ar = AspectRatio.GetAspectRatio(Screen.width, Screen.height); if (ar.x == 16f && ar.y == 9f) { wideAspect = true; } Logger.LogDebug($"Wide Aspect: {wideAspect}"); DontDestroyOnLoad(gameObject); if (OverlayCanvas == null) { CanvasUtil.CreateFonts(); OverlayCanvas = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080)); OverlayCanvas.name = "IGTDisplay"; DontDestroyOnLoad(OverlayCanvas); _background = CanvasUtil.CreateImagePanel(OverlayCanvas, new Color32(0x28, 0x28, 0x28, 0x00), wideAspect ? topRightLegacy : topRightHD); _textPanel = CanvasUtil.CreateTMProPanel(_background, string.Empty, 24, TextAnchor.UpperLeft, new CanvasUtil.RectData(new Vector2(-5, -5), new Vector2(0, 0), new Vector2(0, 0), new Vector2(1, 1))); tmProObjRef = _textPanel.GetComponent <TextMeshProUGUI>(); tmProObjRef.alignment = TextAlignmentOptions.TopRight; } }
void OnGUI() { xy = EditorGUI.Vector2Field(new Rect(3, 3, Screen.width - 6, 10), "Resolution", xy); xy = new Vector2(xy.x < 1 ? 1 : (int)xy.x, xy.y < 1 ? 1 : (int)xy.y); if (GUI.Button(new Rect(3, 50, Screen.width - 6, 40), "Calculate Aspect Ratio\n" + result)) { Vector2 aspectRatio = AspectRatio.GetAspectRatio((int)xy.x, (int)xy.y); result = "Aspect Ratio = " + aspectRatio.x + ":" + aspectRatio.y + " (" + xy.x + "x" + xy.y + ")"; } }
// Use this for initialization void Start() { aspectRatio = AspectRatio.GetAspectRatio(Screen.width, Screen.height); Camera.main.orthographicSize = (1080 * (aspectRatio.y / 9f) / 2) / 100; Sprites = FindObjectsOfType(typeof(GameObject)); foreach (GameObject Sprit in Sprites) { if (Sprit.GetComponent <SpriteRenderer> () && !Sprit.transform.parent) { Sprit.transform.localScale = new Vector3(Sprit.transform.localScale.x * (aspectRatio.x / 16f), Sprit.transform.localScale.y * (aspectRatio.y / 9f), Sprit.transform.localScale.z); Sprit.transform.position = new Vector3(Sprit.transform.position.x * (aspectRatio.x / 16f), Sprit.transform.position.y * (aspectRatio.y / 9f), Sprit.transform.position.z); } } }
void Start() { Vector2 aspect = AspectRatio.GetAspectRatio(Screen.width, Screen.height, true); if (aspect.y == 10) { boundary.minX = -2.55f; boundary.maxX = 2.55f; } else if (aspect.y == 9) { boundary.minX = -2.3f; boundary.maxX = 2.3f; } else if (aspect.y < 3) { boundary.minX = -2.7f; boundary.maxX = 2.7f; } else if (aspect.y < 5) { boundary.minX = -3f; boundary.maxX = 3f; } else if (aspect.y < 6) { boundary.minX = -3f; boundary.maxX = 3f; } else if (aspect.y < 7) { boundary.minX = -2.3f; boundary.maxX = 2.3f; } else { boundary.minX = -2.3f; boundary.maxX = 2.3f; } gray = GetComponent <Grayscale>(); fade = false; Camera = gameObject; offset = transform.position - player.transform.position; }
string GetEmulatorInfo() { if (Emulator == null) { return("未选择模拟器"); } var msg = $"模拟器:{Emulator.Name}"; var nl = Environment.NewLine; if (Emulator.IsAlive) { msg += " 状态:在线"; var resolution = Emulator.GetResolution(); msg += $"{nl}分辨率:{resolution}"; var aspectRatio = AspectRatio.GetAspectRatio(resolution); msg += $" 宽高比:{(aspectRatio?.ToString() ?? "不支持")}"; msg += $"{nl}实际窗口大小:" + (emulator.IsAreaValid() ? GetRectInfo(emulator.Area) : "模拟器区域不合法"); } else { msg += " 状态:离线"; } return(msg); }
public static Vector2 getTransVel(Vector2 Velocity) { aspectRatio = AspectRatio.GetAspectRatio(Screen.width, Screen.height); return(new Vector2(Velocity.x * (aspectRatio.x / 16f), Velocity.y * (aspectRatio.y / 9f))); }
public static float getYVel(float Velocity) { aspectRatio = AspectRatio.GetAspectRatio(Screen.width, Screen.height); return(Velocity * (aspectRatio.y / 9f)); }
/* * This is where fields for various levels are stored */ void Awake() { Application.targetFrameRate = 60; Screen.orientation = ScreenOrientation.LandscapeLeft; Scene activeScene = SceneManager.GetActiveScene(); /* * tweak these settings later */ if ((activeScene.buildIndex == 2) || (activeScene.buildIndex == 5) || (activeScene.buildIndex == 8) || (activeScene.buildIndex == 11)) { DraggingObjects.gravity = -1.0f; DraggingObjects.maxSpeed = 2.0f; } else if ((activeScene.buildIndex == 3) || (activeScene.buildIndex == 6) || (activeScene.buildIndex == 9) || (activeScene.buildIndex == 12)) { DraggingObjects.gravity = -2.0f; DraggingObjects.maxSpeed = 3.0f; } else if ((activeScene.buildIndex == 4) || (activeScene.buildIndex == 7) || (activeScene.buildIndex == 10) || (activeScene.buildIndex == 13)) { DraggingObjects.gravity = -3.0f; DraggingObjects.maxSpeed = 4.0f; } else { DraggingObjects.gravity = -1.0f; DraggingObjects.maxSpeed = 2.0f; } Vector2 aspectRatio = AspectRatio.GetAspectRatio(Screen.width, Screen.height); if (aspectRatio.x == 16 && aspectRatio.y == 9) { Debug.Log("The aspect ratio is 16:9"); Spawner.spawnDomain = 6; } else if (aspectRatio.x == 18 && aspectRatio.y == 9) { Debug.Log("The aspect ratio is 18:9"); Spawner.spawnDomain = 7; } else if (aspectRatio.x == 4 && aspectRatio.y == 3) { Debug.Log("The aspect ratio is 4:3"); Spawner.spawnDomain = 4; } else if (aspectRatio.x == 3 && aspectRatio.y == 2) { Debug.Log("The aspect ratio is 3:2"); Spawner.spawnDomain = 5; } else if (aspectRatio.x == 16 && aspectRatio.y == 10) { Debug.Log("The aspect ratio is 16:10"); Spawner.spawnDomain = 5; } else if (aspectRatio.x == 19 && aspectRatio.y == 9) { Debug.Log("The aspect ratio is 18:10"); Spawner.spawnDomain = 7; } else if (aspectRatio.x == 5 && aspectRatio.y == 4) { Debug.Log("The aspect ratio is 5:4"); Spawner.spawnDomain = 4; } else if (aspectRatio.x == 8 && aspectRatio.y == 5) { Debug.Log("The aspect ratio is 8:5"); Spawner.spawnDomain = 5; } else if (aspectRatio.x == 5 && aspectRatio.y == 3) { Debug.Log("The aspect ratio is 5:3"); Spawner.spawnDomain = 5; } else { Debug.Log("The aspect ratio is undefined"); Spawner.spawnDomain = 4; } }