Article Directory
-
-
- I. Introduction
- Two, Unity common windows
-
- 1. Six Unity windows
- 2. Game window resolution setting
- 3. Hiding the 3D icon in the Scene window
- 4. Mutual synchronization of camera and Scene window perspective
- 5. Putting away and unfolding the Inspector component
- 6. Collapse and expand the tree nodes of the Hierarchy window
- 7, Project window filtering
- 8. Console log window
- 9, PackageManager window
- 10. Player Settings window
- Three, Player Settings window commonly used settings
-
- 1. Set the game name
- 2. Set the Bundle ID
- 3. Set the version number
- 3. Set the game icon
- 4. HD game icon compression format setting
- 5. Set the splash screen
- 6. Horizontal and vertical screen settings
- 7. Set the macro definition
- 8. Platform CPU type setting
- 9. Set up multi-threaded rendering
- 10. Set the lock frame rate
- 11. Set a fixed time step (physical update)
- 12. Set the physical collision of the layer
- 13, set up the Layer layer
- 14. Set Tags
- 15. Set engine code clipping
- Four, other settings
- Five, the code is commonly used
-
I. Introduction
I wrote an article about Unity
commonly used tips and settings before, but now Unity2020
, there are some small adjustments, so let's write an article about Unity2020
it.
Two, Unity common windows
1. Six Unity windows
Unity
The six main windows ( Scene、Game、Inspector、Hierarchy、Project、Console
) are included in the Window - General
menu, and the corresponding shortcut keys can be remembered, at least Console
the shortcut keys of the window Ctrl+Shift+C
.
2. Game window resolution setting
Game
Clicking under the view label will pull down the resolution list. Unity
The commonly used resolutions have been built into the list, and we can also +
add custom resolutions in dots .
3. Hiding the 3D icon in the Scene window
As shown below, a big 3D
icon is in the Scene
view, blocking us, Cube
and it is very eye-catching.
Just remove the check in the Scen
view. But there is still a small camera . We can click the button directly to connect the camera. Will not show upGizmos
3D Icons
icon
Gizmos
icon
4. Mutual synchronization of camera and Scene window perspective
4.1. The camera angle of view is synchronized to the Scene window angle of view.
Select the camera and click the menu GameObject - Align View to Selected
. At this time, the selected Scene
window will be based on the camera angle of view
4.2. The scene window angle of view is synchronized to the camera angle of view.
Select the camera and click the menu GameObject - Align With View
. At this time, the selected camera will be based on the Scene
window angle of view
5. Putting away and unfolding the Inspector component
Collapse All Components
Collapse All Component
Expand All Components
Expand AllComponent
6. Collapse and expand the tree nodes of the Hierarchy window
Select a node, press to Alt+向左
collapse all nodes, and press to Alt+向右
expand all nodes.
7, Project window filtering
Filter according to file type to facilitate quick file search
8. Console log window
There are several buttons in the window
Collapse
: store log, it will store the same output
Clear on Play
: Unity
when running, it will clean up the log
Error Pause
: when there is Error
output, Unity
stop running
=Often planning or artists accidentally clicked Error Pause when using Unity, and then an Error log appeared when running, Unity halted the operation, and then shouted in surprise: "Ah, my unity is stuck"
9, PackageManager window
Unity 2018.1
The version began to introduce the package manager Package Manager
window, which Window - Package Manager
can be opened
by clicking the menu Package Manager
. We can install, remove or update Unity
many great plugin packages, such as Shader Graph、Timeline、ProBuilder、Android Logcat
etc.
If one of the searched plug-in packages cannot be found, first make sure that the filter is selected hereUnity Registry
10. Player Settings window
Many packaging-related settings are in the Player Settings
window, and many settings mentioned below are related to this window.
Click on the menu: File - Build Settings
open the Build Settings
window,
and then click Player Settings
,
you can open the Player Settings
window, in fact, it is the Project Settings
window Player
tab window
Three, Player Settings window commonly used settings
1. Set the game name
You Product Name
can fill in the name of the game on the right and
set it by code:
UnityEditor.PlayerSettings.productName = "testgame";
2. Set the Bundle ID
Open the Other Settings
drop-down page, and Package Name
fill in the package name ( Bundle ID
) on the right . The general format is com.公司名.游戏名
code setting:
// Unity5.x之前
UnityEditor.PlayerSettings.bundleIdentifie = "com.linxinfa.mygame";
// Unity2017以后
UnityEditor.PlayerSettings.applicationIdentifier = "com.linxinfa.mygame";
3. Set the version number
Open the Other Settings
drop-down page, Version*
and Bundle Version Code
you can fill in the version number on the and right side. It is
recommended to use the code to set:
UnityEditor.PlayerSettings.bundleVersion = "1.0.0";
#if UNITY_ANDROID
UnityEditor.PlayerSettings.Android.bundleVersionCode = 1;
#elif UNITY_IOS
UnityEditor.PlayerSettings.iOS.buildNumber = "1";
#endif
For the difference between Bundle Identifier, Bundle Version, and Bundle Version Code, please refer to my article: https://linxinfa.blog.csdn.net/article/details/87693138
3. Set the game icon
Open the Icon
drop-down page to set the game icon
code mode setting:
PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup platform,Texture2D[] icons);
Pay attention to the second parameter icons array, Android must pass6 icons, IOS must pass15 icons, Otherwise the interface call is invalid.
Unity uses code to set the game icon, you can refer to my blog: https://blog.csdn.net/linxinfa/article/details/84248474
4. HD game icon compression format setting
See my blog:
Unity game icon compression format settings (to solve the problem of unclear icons): https://blog.csdn.net/linxinfa/article/details/84140334
5. Set the splash screen
Open the Splash Image
drop-down page to set the game splash screen.
Unity
Use the code to set the Splash Screen splash screen. Please refer to my blog: https://blog.csdn.net/linxinfa/article/details/87694417
6. Horizontal and vertical screen settings
Open the Resolution and Pressentation
drop-down page, on the Default Orientation*
right, you can select the default horizontal and vertical screens.
Code mode settings:
Screen.orientation = ScreenOrientation.LandscapeRight;
7. Set the macro definition
Open the Other Settings
pull-down page, Scripting Define Symbols
you can set the macro definition, a plurality of macro separated by semicolons
#if MY_DEFINE1
Debug.Log("Hello MY_DEFINE1");
#endif
#if MY_DEFINE2
Debug.Log("Hello MY_DEFINE2");
#endif
8. Platform CPU type setting
Open the Other Settings
pull-down page, Target Architectures
you can check the publishing platform supported under CPU
the type of
image above ARM64
can not be checked because the Scripting Backend
use is Mono
, if you want to support ARM64
, you Scripting Backend
must selectIL2CPP
9. Set up multi-threaded rendering
Open the Other Settings
drop-down page, check it Multithread Rendering
to support multi-threaded rendering
About multi-threaded rendering: https://zhuanlan.zhihu.com/p/44116722
10. Set the lock frame rate
Then click on the Quality
page to VSync Count
set it to Don't Sync
. If it is not set Don't Sync
, the frame rate locked in the code will not take effect.
Then set the frame rate in the code:
Application.targetFrameRate = 30;
11. Set a fixed time step (physical update)
Click on the Time
page Fixed Timestep
to set the fixed time step
for physics update on the right. For a stable physics simulation, a fixed time step ( fixed time stepping
) is very important, and the physical calculation must be performed independently of the frame rate of the game. rigidbody
Physical calculations such as collision detection and rigid body ( ) movement are performed in discrete fixed time steps independent of the frame rate.
Code setting:
Time.fixedDeltaTime = 0.02f;
12. Set the physical collision of the layer
Click on Physics
the page, in Layer Collision Matrix
the collision can be checked between different physical layers, for the layer need not be calculated physical impact, can be √
removed to improve performance.
13, set up the Layer layer
Click on the Tags and Layers
page to open the Layers
drop-down page to edit and add new Layer
layers
14. Set Tags
Click on the Tags and Layers
page to open the Tags
drop-down page to edit and add newTags
15. Set engine code clipping
This is only available in the Apple version Unity
.
In Player Settings
the Other Settings
drop-down page of the window , there is one Strip Engine Code
. After checking it, the code will be tailored when packaging, and the unused code will not be packaged. For example, if a 2D
game does not use Rigidbody
other physical components, then the Rigidbody
relevant code of the engine will be It is cut out to reduce the package body.
However, this feature should be used with caution, because I've run
into trouble , you can refer to my previous blog: "Unity loads resource instantiation through AssetBundle to solve the problem of crashing on iOS (caused by Strip)": https://blog.csdn. net/linxinfa/article/details/79757492
Four, other settings
1. Save file prompt settings
Open Preferences
window, menu:, Edit - Preferences
open General
page, checkVerify Saving Assets
In this way, when Unity
you press ctrl+s
save in the editor, a query box will pop up to ask whether you want to save the modified file.
We can selectively save
2. Download and configure Android Build Support
Recommended to Unity Hub
installAndroid Build Support
3. Set up JDK, Android SDK, NDK, Gradle
Through the Unity Hub
installation Android Build Support
, the downloads are JDK、Android SDK、NDK、Gradle
all in the directory in the following figure: Unity安装目录\Editor\Data\PlaybackEngines\AndroidPlayer
click the menu Edit - Preferences...
, open the Preferences
window, select the External Tools
page, you can set JDK、Android SDK、NDK、Gradle
, and the default is to tick.
Five, the code is commonly used
1. Frame rate FPS
var fps = 1.0f / Time.smoothDeltaTime();
2. Debug.Log outputs log with color
Debug.Log(string.Format("<color=#ff0000>{0}</color>", "hello world"));
Debug.Log(string.Format("<color=yellow>{0}</color>", "welcome to unity"));
Hexadecimal color code table
https://www.sioe.cn/yingyong/yanse-rgb-16/
3. Capture Unity log and upload to the server
See my blog: https://linxinfa.blog.csdn.net/article/details/107221307
4. Screenshot function
See my blog: https://linxinfa.blog.csdn.net/article/details/49493775
5. Unity file operation path
See my blog: https://linxinfa.blog.csdn.net/article/details/51679528