کانال تخصصی یونیتی ( آموزش و نکته )
前往频道在 Telegram
به نام خدا مسئولیت مطالب یا آگهی ارسالی در کانال یا کامنت ها به عهده من یا ما نیست لیست گروه ها و... https://t.me/UnityEngine3D/823 برای تبلیغ در کانال و گروه : https://t.me/UnityEngine3DAds مدیر اصلی(مالک) @UnityEngine
显示更多1 790
订阅者
-224 小时
-27 天
+530 天
帖子存档
دوستان یه برنامه هست به اسم باسلام ، توش کلی چیز هست ، کسی خواست نصب کنه (خودم بیشتر کتاب هایی که پیدا نمیکردم یا گرون تر بودن نسبت به باسلام رو از اینجا خریدم ، بد نبود)
خواستید از داخل لینک زیر برید تا برای خرید اولتون (اینطور که نوشته بود) ۳۰ هزار تومن اعتبار بهتون بده 👇
https://basalam.com/user/DZzVEo/invite/app
(حتما از داخل این لینک برید😑)
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 👈
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 👈
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 👈
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 👈
You can use [𝗧𝗲𝘅𝘁𝗔𝗿𝗲𝗮] attribute to make your string input field larger in the inspector
https://docs.unity3d.com/ScriptReference/TextAreaAttribute.html
#نکته #یونیتی
👉 @UnityEngine3D 👈
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 👈
وقتی که یک Asset که توی AssetStore دیدی رو توی یک بازی پیدا میکنی 😂
#meme
👉 @UnityEngine3D 👈
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 👈
با این ربات میتونی از اینستاگرام بدون محدودیت حجم دانلود کنی
@igEasyBot
فقط کافیه لینک پست یا igtv یا reel رو براش بفرستی و دانلود میشه
میتونی آدرس یه پیج رو بفرستی و برات عکس پروفایل اون پیج رو با کیفبت میفرسته
@igEasyBot
This would be a way to do it inefficiently
#نکته #یونیتی
👉 @UnityEngine3D 👈
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 👈
1⃣6⃣ Profile your code first, before any optimization attempt. The thing I mention heavily in my blog post on one micro-optimization https://gamedev.center/array-vs-dictionary-lookup-in-net/
1⃣7⃣ Reduce amount of API calls that return an array. Make sure to use non-allocating equivalent if available.
1⃣8⃣ Know how your data structures work internally. When to use Array, List, Dictionary, HashSet etc.
1⃣9⃣ You can use double collection when you need to iterate frequently over the collection, but also need key access.
2⃣0⃣ If you need Dictionary with MonoBehaviour or ScriptableObject key, then use id = MonoBehaviour.GetInstanceId() and make it an int-keyed Dictionary using this id as a key.
2⃣1⃣ The C# integer-keyed dictionary is highly optimized with hand-written IL code by the Xamarin team. But don’t use it every time, use only for dictionaries that are indexed 100-1000s times per frame.
2⃣2⃣ Use inlining for very hot path methods. You can even consider manual inlining, but profile first. After .NET 4.6 inlining via attribute should be fine too.
2⃣3⃣ Use fields instead of properties in a hot path.
2⃣4⃣ What happens when Canvas rebuilds its mesh: recalculate layout, regenerate mesh, regenerate materials.
2⃣5⃣ When UI element is dirty the mesh for it will be regenerated even if alpha is 0.
2⃣6⃣ Changing the color of a graphic only dirties it’s vertices. Changing Fill* properties also dirties only vertices. So no Canvas mesh rebuild is needed.
2⃣7⃣ UI elements are sorted by depth, yes, it includes sort() operation call, which is O(n log n) operation.
Again the tip from the previous year: UI is transparent, so everything is rendered all the time – overdraw can be a problem.
2⃣8⃣ Nesting canvases is a good practice, as dirtying a child canvas does not dirty the parent. Child canvases maintain own geometry and perform own batching.
2⃣9⃣ When splitting canvases, group elements that are updated simultaneously.
Separate dynamic elements from static ones.
3⃣0⃣ Use object pooling for large ScrollRects with many elements.
Add a separate sub Canvas for large ScrollRects.
Turn off pixel perfect for Canvas that wraps a large ScrollRect.
Modify the code to stop ScrollRect when velocity is low.
3⃣1⃣ Turn off “Rayast Target” box whenever possible.
3⃣2⃣ Always assign Event Camera property in Canvas component.
3⃣3⃣ FindObjectWithTag() is not as bad as FindObjectOfType(). But obviously the more game objects with tag are indexed, the slower it works.
3⃣4⃣ Always assign World Camera for world space canvases.
3⃣5⃣ Do not add Graphic Raycaster to non-interactive elements.
3⃣6⃣ Layout components are painfully slow.
3⃣7⃣ Each Layout Group multiplies its cost. Nested Layout Groups are particularly bad.
3⃣8⃣ What marks layout dirty: OnEnable, OnDisable, reparenting (twice: for the new and the old parent), OnDidApplyAnimatorProperties, OnRectTransformDimensionsChanged.
3⃣9⃣ Use anchors instead of Layout Group for proportional UIs.
For a truly dynamic UI write custom code to maintain its layout, you know better how your UI must work. Update UI on demand.
4⃣0⃣ When using Object Pool for UI elements:
On adding to pool disable game object first, only then reparent.
When getting back from pool reparent first, then update data, and only then enable.
4⃣1⃣ Disable the Canvas component instead of disabling game object.
4⃣2⃣ Never use Animator for UI elements. Animator dirties elements every frame, even if nothing happens visually.
