Unity에서 Windows Build에서 매개변수를 가져오는 방법
Unity에서 Windows Build에서 매개변수를 가져오는 방법
필요에 부닥쳐서 녹음을 잊어버렸어요.using UnityEngine;
using System;
public class Init{
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
string[] cmds = System.Environment.GetCommandLineArgs();
}
}
이렇게 하면 cmds에 파라미터가 있어요.
(cmds[0]는 명령 자체를 포함합니다)
응용 프로그램
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
public class Init :MonoBehaviour{
static List<String> s = new List<string>();
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
string[] cmds = System.Environment.GetCommandLineArgs();
foreach(string cmd in cmds)
{
s.Add((cmd));
}
}
private void Start()
{
Text t = GetComponent<Text>();
if(t != null)
{
t.text = "";
for(int i = 0; i < s.Count; i ++)
{
t.text += " " +s[i];
}
}
}
}
Text가 있는 UI를 적당히 만들어서 붙여서 Exe를 만들어요.
생성된 Exe 파일의 바로 가기를 만들고 바로 가기 속성에 링크 대상에 매개변수를 추가합니다.
하면, 만약, 만약...
파라미터를 뺐습니다.
Reference
이 문제에 관하여(Unity에서 Windows Build에서 매개변수를 가져오는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/miyumiyu/items/4f8fbe25b9cce261f864
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
using UnityEngine;
using System;
public class Init{
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
string[] cmds = System.Environment.GetCommandLineArgs();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.UI;
public class Init :MonoBehaviour{
static List<String> s = new List<string>();
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
string[] cmds = System.Environment.GetCommandLineArgs();
foreach(string cmd in cmds)
{
s.Add((cmd));
}
}
private void Start()
{
Text t = GetComponent<Text>();
if(t != null)
{
t.text = "";
for(int i = 0; i < s.Count; i ++)
{
t.text += " " +s[i];
}
}
}
}
Reference
이 문제에 관하여(Unity에서 Windows Build에서 매개변수를 가져오는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/miyumiyu/items/4f8fbe25b9cce261f864텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)