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:
Sound file:
TextAsset txtAsset = (TextAsset)Resources.Load("textfile", typeof(TextAsset));
A single elf: AudioClip audio = Resources.Load("soundFile", typeof(AudioClip)) as AudioClip;
Texture2D texture = Resources.Load("textureFile", typeof(Texture2D)) as Texture2D;
Sprite sprite = Resources.Load("spriteFile", typeof(Sprite)) as Sprite;
Sprite[] sprite = Resources.LoadAll<Sprite>("spriteFile") as Sprite[];
VideoClip video = Resources.Load("videoFile", typeof(VideoClip)) as VideoClip;
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!