Version: 2023.2
언어: 한국어
UXML 파일 재사용
C# 스크립트에서 UXML 및 USS 로드

UXML에서 다른 파일 레퍼런스

UXML 파일에서 <Template><Style> 요소를 사용하여 다른 UXML 또는 USS 파일을 참조할 수 있습니다.두 요소는 모두 src 속성 또는 path 속성을 허용합니다.

src 속성

Use the following syntax for the src attribute:

src="<path-to-file>/<file-name-with-extension>"

Any errors during import, such as missing files, trigger an error message.

You can use a relative or an absolute path:

  • Absolute paths start from the project’s Assets folder and begin with a / or project://database/. For example, /Assets/myFolder/myFile.uss or project://database/Assets/myFolder/myFile.uss.
  • Relative paths start from the current file and exclude the /. For example, ../myFolder/myFile.uss.

Note: To reference a file from packages, use the absolute path of the package file that starts from the Packages folder. For example, /Packages/com.unity.package.name/file-name.uss or project://database/Packages/com.unity.package.name/file-name.uss. you must use the format of com.unity.package.name rather than package name for the package name.

path 속성

path 속성은 Unity 리소스 메커니즘을 사용하지만 임포트 시 오류 보고 기능을 제공하지 않으며 상대 경로를 허용하지 않습니다.

path 속성은 다음 규칙에 따라 Resources 폴더 또는 Editor Default Resources 폴더에 있는 파일을 허용합니다.

  • 파일이 Resources 폴더에 있는 경우 파일 확장자를 포함하지 마십시오.예를 들어, Assets/Resources/template.uxml에 있는 파일에 대해 path="template"을 작성합니다.
  • 파일이 Editor Default Resources 폴더에 있는 경우 파일 확장자를 포함해야 합니다.예를 들어, Assets/Editor Default Resources/template.uxml에 있는 파일에 대해 path="template.uxml"을 작성합니다.

추가 리소스

UXML 파일 재사용
C# 스크립트에서 UXML 및 USS 로드