当前位置:网站首页>Basic syntax of unity script (6) - specific folder
Basic syntax of unity script (6) - specific folder
2022-07-02 03:28:00 【ht_ game】
stay Unity During the development of the project , You can choose to create any folder that conforms to the specification name to form the directory structure of the whole project . meanwhile ,Unity Defines a series of A folder with a specific name Used to handle specified tasks , For example, the script related to the editor must be placed in Editor Folder can work normally .
Assets
Assets Folder includes Unity All resource files used in the project . newly build Unity After the project , The folder will be created automatically . stay Project The palette ,Assets Use as root folder . also , There is no need to specify , be-all API Method by default, all resource files are located in Assets In the folder .

Editor
Put in Editor The scripts in the folder are regarded as editor scripts , Instead of runtime scripts . The scripts in this folder are only run in the editor during development , Instead of being included build In the next project . Only scripts in this folder can access Unity Editor Of API, So as to expand the editor .
Resources
Resources Folder allows you to access the corresponding resources through the name of the file in the script . Use Resources.Load Method for dynamic loading , Resources placed in this folder are always included build in , Even if not used . Once the project is packaged ,Resources All the resources in the folder are packed into the archive in .
When resources are accessed as script variables , These resources are loaded into memory after the script is instantiated . If resources are too large , These large resources can be put into this folder for dynamic loading ; When these resources are no longer used , call Resources.UnloadUnusedAssets Free memory .
Resources.Load() Loading Assets The resource
resources : The precast body 、 Model 、 texture of material 、 texture 、 Audio 、 video 、 Data document 、 Scene and so on
Be careful :Resources This dynamic loading method is read-only , After the game is packaged , The contents of the folder cannot be modified
Resources Methods
FindObjectsOfTypeAll: Return all resources of a certain type
Load: Through the path ( Or name ) load resources
LoadAll: Load the Resources All resources under
LoadAsync: Load resources asynchronously , Through collaborative process
UnloadAsset: Unload loaded resources
UnloadUnusedAssets: Unload unused resources in memory for minutes
load resources
public class Resource : MonoBehaviour {
void Start()
{
AddObjToScenes();
}
/// <summary>
/// Define a load Resources Methods of resources in folders
/// </summary>
public void AddObjToScenes()
{
// Load resources into the game process
var obj = Resources.Load("123");
// Instantiate an asset into the scene
GameObject instance = Instantiate(obj) as GameObject;
instance.transform.position = Vector3.zero;
// Empty the resource from the process
obj = null;
// Unload loaded resources
Resources.UnloadAsset();
}
}
Plugins
Plugins Folders are used for storing native plug-in unit , These plug-ins will be automatically included build in . stay Windows Under the platform ,native The plug-in is dll file
Plugins The folder must be Assets Direct subdirectories of folders
Gizmos
Unity have access to Gizmos Class in Scene Draw an image in the panel to show the design details , among Gizmos.DrawIcon Function can draw an icon in the scene window to mark special objects and positions , The image file used by this function is located in Gizmos In the folder
StreamingsAssets
When you need to use a resource that retains the original format instead of Unity Format after special processing , Its resources can be placed in StreamingAssets In the folder . The resources in this folder will be copied to the corresponding folder of the target device when the game is installed , Any platform can pass Application.streamingAssetsPath Visit
StandardAssets
StandardAssets The script in the folder is compiled first , These scripts will be exported to Assembly-Csharp-firstpass or Assembly-UnityScript-firstpass In the project . Prevent scripts from this folder , You can use it C# Script to access js Scripts or scripts in other languages
Hide Folder
With .‘’ start 、 With ~ ending 、 With cvs Named or with .tmp Folders with extensions are hidden folders , Resources in hidden folders will not be imported , The script will not be compiled ,Unity The existence of this folder will be completely ignored .
Script Compilation
(1) Compile in StandardAssets、Plugins All scripts in the folder . Scripts in these folders cannot directly access scripts outside these folders , You cannot directly reference a class or its variables , But you can use GameObject.SendMessage Communicate with them .
(2) Compile in StandardAssets/Editor 、 Plugins/Editor All scripts in the folder . If you want to use it UnityEditor Namespace , Scripts must be placed in these folders .
(3) Compile in Assets/Editor Outside and not in step (1) and (2) All script files in .
(4) Compile in Assets/Editor All scripts in
边栏推荐
猜你喜欢

《MATLAB 神經網絡43個案例分析》:第42章 並行運算與神經網絡——基於CPU/GPU的並行神經網絡運算

Analyse de 43 cas de réseaux neuronaux MATLAB: Chapitre 42 opérations parallèles et réseaux neuronaux - - opérations parallèles de réseaux neuronaux basées sur CPU / GPU

Pointer array & array pointer
On redis (II) -- cluster version

Sentry experience and architecture, a fledgling monitoring product with a market value of $100million

NLog使用

"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu

C shallow copy and deep copy

Detailed explanation of the difference between Verilog process assignment

Review materials of project management PMP high frequency examination sites (8-1)
随机推荐
JS <2>
NLog使用
MySQL advanced (Advanced) SQL statement (II)
[yolo3d]: real time detection of end-to-end 3D point cloud input
Global and Chinese markets for electronic laryngoscope systems 2022-2028: Research Report on technology, participants, trends, market size and share
跟着CTF-wiki学pwn——ret2shellcode
《MATLAB 神经网络43个案例分析》:第42章 并行运算与神经网络——基于CPU/GPU的并行神经网络运算
/silicosis/geo/GSE184854_scRNA-seq_mouse_lung_ccr2/GSE184854_RAW/GSM5598265_matrix_inflection_demult
< job search> process and signal
GSE104154_scRNA-seq_fibrotic MC_bleomycin/normalized AM3
SAML2.0 notes (I)
Detailed explanation of ThreadLocal
Verilog avoid latch
表单自定义校验规则
[HCIA continuous update] working principle of OSPF Protocol
Go execute shell command
Verilog 避免 Latch
Global and Chinese market of autotransfusion bags 2022-2028: Research Report on technology, participants, trends, market size and share
《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
aaaaaaaaaaaaa