4⃣3⃣ Default tip: profile everything, trust no one.
4⃣4⃣ String comparison is a pretty complicated topic, so if you use it really heavily make sure to choose the best method for your use case.
4⃣5⃣ Use attribute [Il2CppSetOption(Option,NullChecks, false)] to remove null checks in resulting C++ code.
4⃣6⃣ Use Transform.SetPositionAndRotation() to batch transform updates.
4⃣7⃣ Since Unity 5.4 transforms are stored in a contiguous buffers. There is one TransformHierarchy structure for each root transform in a scene.
4⃣8⃣ TransformChangedDispatch keeps a list of dirty TransformHierarchies pointers. Yes, it operates on a hierarchy level.
4⃣9⃣ Set Transform.hierarchyCapacity if you know the size of the hierarchy. Use it especially before mass reparenting operations.
Set parent and position using GameObject.Instantiate(…) arguments.
5⃣0⃣ Split your transform hierarchies. Smaller hierarchies are better. More root transforms is better since its checking is jobified.
5⃣1⃣ Use Physics.SyncTransforms if you need to propagate transform changes to the PhysX system. Physics.AutoSyncTransforms = true, enables it by default, with performance hit of course.
5⃣2⃣ Batch transform updates before using physics.
Use flat hierarchies instead of deep ones.
5⃣3⃣ AudioSource.mute doesn’t prevent computational work. Disable a muted Audio Source.
5⃣4⃣ FMOD background thread CPU usage is not shown in the profiler. Scroll down to the Audio tab in Unity Profiler for evaluating CPU load by FMOD background audio threads.
5⃣5⃣ Use Vorbis compression on iOS for audio clips.
5⃣6⃣ Avoid having too many Audio Sources put on mute.
5⃣7⃣ Use decompress on load option if you can afford memory overhead. E.g. for short frequent sounds
Avoid playing lots of compressed clips, especially on mobile
5⃣8⃣ FMOD background threads overload can cause framerate stutter, since it has realtime priority and can interrupt the main thread.
5⃣9⃣ Clamp the voice count to save CPU time via
configuration = AudioSettings.GetConfiguration();
configuration.numRealVoices = Mathf.Clamp(configuration.numRealVoices, 1, configuration.numVirtualVoices);
AudioSettings.Reset(configuration);
6⃣0⃣ Animator can push work onto worker threads. Therefore it scales better. But has overhead.
So always test it on the min target hardware.
Consider number of curves in animations.
More cores – better for animator. Animator outperforms Animation on lower amount of animation curves, the more cores/power CPU has.
Use Animation for simple animations.
Use Animator for high curve count clips and complex scenarios.
6⃣1⃣ In Animator active state on each layer is evaluated every frame, even if weight = 0. Zero-weight layers – waste of performance.
6⃣2⃣ Additional layer in Animator increases cost by around 20%.
6⃣3⃣ Use the right rig. Humanoid rig is slower than generic rig. Because humanoid runs IK and retargeting calculations.
6⃣4⃣ Pooling: Animator resets state when its GameObject is disabled. Fixed in 2018.1 by adding Animator.keepControllerStateOnDisable. Useful for pooling, but has higher memory cost for disabled Animators.
6⃣5⃣ Split dynamic and static transforms into separate hierarchies with postprocess scripts that does that split without affecting production flow.
6⃣6⃣ No difference between X root transforms and X additive scenes in terms of how TransformChangedDispatch works.
6⃣7⃣ Use scripts to animate simple UI. Or at least Animation as it has less overhead on start and stop.
منبع :
https://gamedev.center/best-optimization-tips-by-unity-engineers-at-unite/
👉 @UnityEngine3D 👈
4⃣4⃣ String comparison is a pretty complicated topic, so if you use it really heavily make sure to choose the best method for your use case.
4⃣5⃣ Use attribute [Il2CppSetOption(Option,NullChecks, false)] to remove null checks in resulting C++ code.
4⃣6⃣ Use Transform.SetPositionAndRotation() to batch transform updates.
4⃣7⃣ Since Unity 5.4 transforms are stored in a contiguous buffers. There is one TransformHierarchy structure for each root transform in a scene.
4⃣8⃣ TransformChangedDispatch keeps a list of dirty TransformHierarchies pointers. Yes, it operates on a hierarchy level.
4⃣9⃣ Set Transform.hierarchyCapacity if you know the size of the hierarchy. Use it especially before mass reparenting operations.
Set parent and position using GameObject.Instantiate(…) arguments.
5⃣0⃣ Split your transform hierarchies. Smaller hierarchies are better. More root transforms is better since its checking is jobified.
5⃣1⃣ Use Physics.SyncTransforms if you need to propagate transform changes to the PhysX system. Physics.AutoSyncTransforms = true, enables it by default, with performance hit of course.
5⃣2⃣ Batch transform updates before using physics.
Use flat hierarchies instead of deep ones.
5⃣3⃣ AudioSource.mute doesn’t prevent computational work. Disable a muted Audio Source.
5⃣4⃣ FMOD background thread CPU usage is not shown in the profiler. Scroll down to the Audio tab in Unity Profiler for evaluating CPU load by FMOD background audio threads.
5⃣5⃣ Use Vorbis compression on iOS for audio clips.
5⃣6⃣ Avoid having too many Audio Sources put on mute.
5⃣7⃣ Use decompress on load option if you can afford memory overhead. E.g. for short frequent sounds
Avoid playing lots of compressed clips, especially on mobile
5⃣8⃣ FMOD background threads overload can cause framerate stutter, since it has realtime priority and can interrupt the main thread.
5⃣9⃣ Clamp the voice count to save CPU time via
configuration = AudioSettings.GetConfiguration();
configuration.numRealVoices = Mathf.Clamp(configuration.numRealVoices, 1, configuration.numVirtualVoices);
AudioSettings.Reset(configuration);
6⃣0⃣ Animator can push work onto worker threads. Therefore it scales better. But has overhead.
So always test it on the min target hardware.
Consider number of curves in animations.
More cores – better for animator. Animator outperforms Animation on lower amount of animation curves, the more cores/power CPU has.
Use Animation for simple animations.
Use Animator for high curve count clips and complex scenarios.
6⃣1⃣ In Animator active state on each layer is evaluated every frame, even if weight = 0. Zero-weight layers – waste of performance.
6⃣2⃣ Additional layer in Animator increases cost by around 20%.
6⃣3⃣ Use the right rig. Humanoid rig is slower than generic rig. Because humanoid runs IK and retargeting calculations.
6⃣4⃣ Pooling: Animator resets state when its GameObject is disabled. Fixed in 2018.1 by adding Animator.keepControllerStateOnDisable. Useful for pooling, but has higher memory cost for disabled Animators.
6⃣5⃣ Split dynamic and static transforms into separate hierarchies with postprocess scripts that does that split without affecting production flow.
6⃣6⃣ No difference between X root transforms and X additive scenes in terms of how TransformChangedDispatch works.
6⃣7⃣ Use scripts to animate simple UI. Or at least Animation as it has less overhead on start and stop.
منبع :
https://gamedev.center/best-optimization-tips-by-unity-engineers-at-unite/
👉 @UnityEngine3D 👈
👍3❤2
This media is not supported in your browser
VIEW IN TELEGRAM
You can have multiple inspectors for different objects open at the same time, all you need to do is add an inspector window and lock it on an object by clicking the small lock🔓 icon on the top right.
#نکته #یونیتی
👉 @UnityEngine3D 👈
#نکته #یونیتی
👉 @UnityEngine3D 👈
👍3❤1
Simple way to control wall hits and not falling from cliffs on Unity's Terrain (heightmap). You can disable collisions between character and terrain and used the code in the pic
#نکته #یونیتی
👉 @UnityEngine3D 👈
#نکته #یونیتی
👉 @UnityEngine3D 👈
You can use [𝗧𝗲𝘅𝘁𝗔𝗿𝗲𝗮] attribute to make your string input field larger in the inspector
https://docs.unity3d.com/ScriptReference/TextAreaAttribute.html
#نکته #یونیتی
👉 @UnityEngine3D 👈
https://docs.unity3d.com/ScriptReference/TextAreaAttribute.html
#نکته #یونیتی
👉 @UnityEngine3D 👈
This media is not supported in your browser
VIEW IN TELEGRAM
If you would like to change a shader property via scripting like this:
material.SetFloat("_Glossiness", 0.5f);
You can get the string by selecting gear wheel of the shader component & click on "Select Shader" to see a list of exposed properties.
#نکته #یونیتی
👉 @UnityEngine3D 👈
material.SetFloat("_Glossiness", 0.5f);
You can get the string by selecting gear wheel of the shader component & click on "Select Shader" to see a list of exposed properties.
#نکته #یونیتی
👉 @UnityEngine3D 👈
When you destroy an AudioSource, the AudioClip will not be unloaded from the memory. You can use UnloadAudioData to do so. This works only for AudioClips that are based on actual sound file assets
#نکته #یونیتی
👉 @UnityEngine3D 👈
#نکته #یونیتی
👉 @UnityEngine3D 👈
👍5
You can access the child objects of a parent object with a 𝗳𝗼𝗿𝗲𝗮𝗰𝗵 𝗹𝗼𝗼𝗽 using 𝗽𝗮𝗿𝗲𝗻𝘁 𝘁𝗿𝗮𝗻𝘀𝗳𝗼𝗿𝗺 as a collection reference
It works because 𝗧𝗿𝗮𝗻𝘀𝗳𝗼𝗿𝗺 component implements IEnumerable interface
#نکته #یونیتی
👉 @UnityEngine3D 👈
It works because 𝗧𝗿𝗮𝗻𝘀𝗳𝗼𝗿𝗺 component implements IEnumerable interface
#نکته #یونیتی
👉 @UnityEngine3D 👈
👍2👏1
This media is not supported in your browser
VIEW IN TELEGRAM
If the cinemachine camera frustum gets in the way of your lighting work and you can't find the Gizmo to turn it off just collapse the Cinemachine Brain Component and it will disappear
#نکته #یونیتی
👉 @UnityEngine3D 👈
#نکته #یونیتی
👉 @UnityEngine3D 👈
👍1
This media is not supported in your browser
VIEW IN TELEGRAM
did you know that you can add animation callbacks when an animation started and ended without adding events to every single animation?
just add this code to your animator controller animation :
#نکته #یونیتی
👉 @UnityEngine3D 👈
just add this code to your animator controller animation :
#نکته #یونیتی
👉 @UnityEngine3D 👈
👍1🔥1