Home > Backend Development > C++ > How Can I Access Resources in the Unity Resources Folder on HoloLens After Deployment?

How Can I Access Resources in the Unity Resources Folder on HoloLens After Deployment?

DDD
Release: 2025-01-28 19:11:09
Original
310 people have browsed it

How Can I Access Resources in the Unity Resources Folder on HoloLens After Deployment?

HoloLens Resource Management: Solving the problem after the deployment is deployed

Problem description:

During the HoloLens deployment, the files in the Unity Resources folder cannot be accessed. After compilation, there is no resourceS or assets directory in the generated solution, resulting in unavailable resources, such as text, images, and audio files.

Solution: Bypassing the traditional file access method

In order to solve this problem, you need to avoid using the traditional method of reading the Resources directory to read the Resources directory. Unity provides a special method called Resources.load, which is specially used for this purpose. Use Resources.load to access resources

When using resources.load, remember the following principles:

Path grammar:

The resource path should be compared to the Resources folder in the project ASSETS folder.

does not include extension names:
    When specified the resource path, do not include file extension names (.txt, .png, .mp3, etc.).
  • The sub -folder uses positive slope: When the resource is located in the subfolder, use the positive slope (/) instead of the back slope ().
  • Load different types of resources
  • Using Resources.load, you can access various types of resources:
  • Text file:

Sound file:

    Image file:
  • TextAsset txtAsset = (TextAsset)Resources.Load("textfile", typeof(TextAsset)); A single elf:
  • Multiple elves: AudioClip audio = Resources.Load("soundFile", typeof(AudioClip)) as AudioClip;
  • Video file (unity & gt; = 5.6): Texture2D texture = Resources.Load("textureFile", typeof(Texture2D)) as Texture2D;
  • Game object: Sprite sprite = Resources.Load("spriteFile", typeof(Sprite)) as Sprite;
  • 3D grid (FBX):
  • Sprite[] sprite = Resources.LoadAll<Sprite>("spriteFile") as Sprite[];
  • asynchronous loading
  • To load the resources asynchronous, use Resources.loadasync method. This is very useful for minimizing the decline in frame declines in the loading process: VideoClip video = Resources.Load("videoFile", typeof(VideoClip)) as VideoClip;
  • Visit the resources in the subclase GameObject prefab = Resources.Load("shipPrefab", typeof(GameObject)) as GameObject; To access the resources stored in the subfolder, please use the positive slope in the path parameter, for example:

The above is the detailed content of How Can I Access Resources in the Unity Resources Folder on HoloLens After Deployment?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template