Get it on Google Play


Wm뮤 :: 유니티 창위치 설정

블로그 이미지
가끔 그림그리거나 3D모델링하거나
취미로 로봇만드는
퇴직한 전자과 게임프로그래머
2020.3.48f1 , 2022.3.6f1 주로 사용
모카쨩
@Ahzkwid

Recent Comment

Archive


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
posted by 모카쨩

  • total
  • today
  • yesterday

Recent Post

저사양 유저용 블로그 진입