2022. 6. 18. 10:37
Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using System;
public class WindowPosition : MonoBehaviour
{
public int x = 0;
public int y = 0;
#if UNITY_STANDALONE_WIN
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
private static extern bool SetWindowPos(IntPtr hwnd, int hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
public static extern IntPtr FindWindow(string className, string windowName);
public IEnumerator SetWindowPosition(int x, int y)
{
yield return new WaitForEndOfFrame();
yield return new WaitForEndOfFrame();
SetWindowPos(FindWindow(null, Application.productName), 0, x, y, 0, 0, 5);
}
public IEnumerator SetWindowPosition(float x, float y)
{
StartCoroutine(SetWindowPosition(Screen.width * x, Screen.height * y));
yield return null;
}
#endif
// Start is called before the first frame update
void Start()
{
#if UNITY_STANDALONE_WIN
StartCoroutine(SetWindowPosition(x,y));
#endif
}
// Update is called once per frame
void Update()
{
}
}
https://forum.unity.com/threads/setting-player-window-position.534733/
이쪽 소스를 간략화 한 버전으로 만들어봤다
윈도우모드 설정시
'Unity' 카테고리의 다른 글
유니티 파티클, 트레일, 라인 렌더러 (0) | 2023.01.21 |
---|---|
유니티 csv 에셋 (0) | 2022.04.30 |
유니티 차트 (0) | 2022.04.24 |