Unity Web Request Creating Unity Web Requests
Create and configure a UnityWebRequest using its available constructors.
읽는 시간 1분최근 업데이트: 한 달 전
WebRequest는 다른 오브젝트처럼 인스턴스화할 수 있습니다. 다음 두 가지 생성자를 사용할 수 있습니다.
- 파라미터가 없는 표준 생성자는 모든 설정이 비어 있거나 기본값인 새 UnityWebRequest를 생성합니다. 타겟 URL이 설정되지 않고, 커스텀 헤더가 설정되지 않으며, 리디렉션 제한이 32로 설정됩니다.
- 두 번째 생성자는 문자열 인자를 취합니다. UnityWebRequest의 타겟 URL을 문자열 인수의 값에 할당하며, 그 외에는 파라미터가 없는 생성자와 동일합니다.
UnityWebRequest를 설정하고 상태를 추적하고 결과를 확인하는 데 사용할 수 있는 기타 여러 프로퍼티가 있습니다.
예제
UnityWebRequest wr = new UnityWebRequest(); // Completely blankUnityWebRequest wr2 = new UnityWebRequest("https://www.mysite.com"); // Target URL is set// the following two are required to web requests to workwr.url = "https://www.mysite.com";wr.method = UnityWebRequest.kHttpVerbGET; // can be set to any custom method, common constants providedwr.useHttpContinue = false;wr.chunkedTransfer = false;wr.redirectLimit = 0; // disable redirectswr.timeout = 60; // don't make this small, web requests do take some time