{"id":331690,"date":"2022-04-08T15:00:09","date_gmt":"2022-04-08T15:00:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331690"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331690","title":{"rendered":"<span>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 Unity \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c PVS-Studio<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Unity \u2013 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0434\u0432\u0438\u0436\u043a\u043e\u0432. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0436\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0421 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0448\u043b\u043e \u043f\u043e\u0447\u0442\u0438 4 \u0433\u043e\u0434\u0430. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6ec\/3d2\/e5f\/6ec3d2e5f549df537eab8c2e4aa7fac8.png\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6ec\/3d2\/e5f\/6ec3d2e5f549df537eab8c2e4aa7fac8.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0420\u0430\u043d\u0435\u0435 \u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u043b\u0438 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0568\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043f\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 Unity. \u0414\u0443\u043c\u0430\u044e, \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0439. \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u044b\u0441\u044f\u0447\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u044f\u0442 \u0441\u0432\u043e\u0451 \u0432\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0430\u0445, \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Unity. \u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0434\u043e\u043b\u0433\u043e \u0431\u0435\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0432\u0435\u0434\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043b\u044e\u0434\u0435\u0439.<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u0432\u0438\u0436\u043a\u0430 Unity \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"https:\/\/github.com\/Unity-Technologies\/UnityCsReference\/tree\/98cc8a97afc8cb990bc0c89165bdb276cbcc8ec4\">2022.1.0b8<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/h3>\n<h4>Issue 1<\/h4>\n<pre><code class=\"cs\">private void Draw(Rect windowRect) {   var rect = new Rect(....);   ....   if (m_NumFilteredVariants > 0)   {     ....             if (m_NumFilteredVariants > maxFilteredLength)     {       GUI.Label(....);       rect.y += rect.height;     }   }   else   {     GUI.Label(rect, \"No variants with these keywords\");     rect.y += rect.height;                               \/\/ &lt;=   }    rect.y = windowRect.height - kMargin - kSpaceHeight \u2013      EditorGUI.kSingleLineHeight;                         \/\/ &lt;=   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3008\/\">V3008<\/a> The &#8216;rect.y&#8217; variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 370, 366. ShaderVariantCollectionInspector.cs 370<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>rect.y<\/em> \u0434\u0432\u0430\u0436\u0434\u044b \u043f\u043e\u0434\u0440\u044f\u0434 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c <em>m_NumFilteredVariants > maxFilteredLength<\/em> \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e, \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u043c\u044b\u0441\u043b\u0430.<\/p>\n<h4>Issue 2<\/h4>\n<pre><code class=\"cs\">public static string FetchBuiltinDescription(....) {   return string.IsNullOrEmpty(version?.packageInfo?.description) ?     string.Format(L10n.Tr(....), version.displayName) :     version.packageInfo.description.Split(....)[0]; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3042\/\">V3042<\/a> Possible NullReferenceException. The &#8216;?.&#8217; and &#8216;.&#8217; operators are used for accessing members of the &#8216;version&#8217; object UpmPackageDocs.cs 38<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0447\u043b\u0435\u043d\u0430\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>version<\/em> \u0431\u0443\u0434\u0435\u0442 <em>null<\/em>, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 <em>IsNullOrEmpty<\/em> \u0432\u0435\u0440\u043d\u0451\u0442 <em>true,<\/em> \u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a <em>displayName<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em>.<\/p>\n<h4>Issue 3<\/h4>\n<pre><code class=\"cs\">public void SetScaleFocused(Vector2 focalPoint,                             Vector2 newScale,                             bool lockHorizontal,                             bool lockVertical) {   if (uniformScale)     lockHorizontal = lockVertical = false;   else   {     if (hZoomLockedByDefault)       lockHorizontal = !lockHorizontal;      if (hZoomLockedByDefault)       lockVertical = !lockVertical;   } .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3029\/\">V3029<\/a> The conditional expressions of the &#8216;if&#8217; statements situated alongside each other are identical. Check lines: 930, 933. ZoomableArea.cs 930<\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043f\u043e\u0434\u0440\u044f\u0434. *<em>hZoomLockedByDefault<\/em> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u044f\u0434\u043e\u043c \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <em>vZoomLockedByDefault<\/em>.<\/p>\n<pre><code class=\"cs\">internal class ZoomableArea {   ....   \/\/ Zoom lock settings   public bool hZoomLockedByDefault = false;   public bool vZoomLockedByDefault = false;   .... } <\/code><\/pre>\n<p>\u0412\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440.<\/p>\n<h4>Issue 4<\/h4>\n<pre><code class=\"cs\">private void UpdateTextFieldVisibility() {   if (showInputField)   {     ....   }   else if (inputTextField != null &amp;&amp; inputTextField.panel != null)   {     if (inputTextField.panel != null)                         \/\/ &lt;=       inputTextField.RemoveFromHierarchy();      inputTextField.UnregisterValueChangedCallback(OnTextFieldValueChange);     inputTextField.UnregisterCallback&lt;FocusOutEvent>(OnTextFieldFocusOut);     inputTextField = null;   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;inputTextField.panel != null&#8217; is always true. BaseSlider.cs 648<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>inputTextField.panel != null<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e.<\/p>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0430\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0448\u0435 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435, \u043d\u043e \u043e\u0448\u0438\u0431\u043b\u0438\u0441\u044c.<\/p>\n<h4>Issue 5<\/h4>\n<p>\u0411\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">public enum EventType {   ....   \/\/ Mouse button was released.   MouseUp = 1,   ....   \/\/ Already processed event.   Used = 12,   .... } public static void MinMaxScroller(....) {   ....   if (   Event.current.type == EventType.MouseUp        &amp;&amp; Event.current.type == EventType.Used)    {     scrollControlID = 0;   }    .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression is always false. Probably the &#8216;||&#8217; operator should be used here. EditorGUIExt.cs 141<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0430\u0448\u0451\u043b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u043e\u0436\u043d\u043e. \u041a\u0430\u043a\u043e\u0435 \u0431\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0438 \u0432\u0435\u0440\u043d\u0443\u043b\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">public static void MinMaxScroller(....) {   ....   if (   Event.current.type == EventType.MouseUp        || Event.current.type == EventType.Used)    {     scrollControlID = 0;   }   .... } <\/code><\/pre>\n<h4>Issue 6<\/h4>\n<pre><code class=\"cs\">private List&lt;T> GetChildrenRecursively(....) {   if (result == null)     result = new List&lt;T>();   if (m_Children.Any())   {     var children = sorted ? (....)m_Children.OrderBy(c => c.key)                                             .OrderBy(c => c.m_Priority)                            : m_Children;     foreach (var child in children)       child.GetChildrenRecursively(sorted, result);   }   else if (value != null)     result.Add(value);   return result; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3078\/\">V3078<\/a> Original sorting order will be lost after repetitive call to &#8216;OrderBy&#8217; method. Use &#8216;ThenBy&#8217; method to preserve the original sorting. MenuService.cs 499<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432 \u043a\u043e\u0434\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \u0434\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <em>OrderBy<\/em>.<\/p>\n<p>\u041a\u0430\u043a \u043f\u043e \u043c\u043d\u0435, \u0442\u0430\u043a \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <em>OrderBy<\/em> \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0438. \u042d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0448\u0438\u0431\u043a\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0445\u043e\u0442\u0435\u043b \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0443, \u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430. \u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0434\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <em>OrderBy<\/em> \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0443, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443. \u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e <em>OrderBy<\/em> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>ThenBy<\/em>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0435 &#171;\u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442&#187;. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441 <em>ThenBy<\/em> \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432. \u0417\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0928\/\">\u0437\u0430\u043c\u0435\u0442\u043a\u0435<\/a>.<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, PVS-Studio \u043d\u0430\u0448\u0451\u043b \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: <a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3078\/\">V3078<\/a> Original sorting order will be lost after repetitive call to &#8216;OrderBy&#8217; method. Use &#8216;ThenBy&#8217; method to preserve the original sorting. SearchSelector.cs 177<\/p>\n<h4>Issue 7<\/h4>\n<pre><code class=\"cs\">public void IconSectionGUI(NamedBuildTarget namedBuildTarget,....) {   ....   if (platformUsesStandardIcons)   {     var selectedDefault = (m_SelectedPlatform &lt; 0);     \/\/ Set default platform variables     BuildPlatform platform = null;     namedBuildTarget = NamedBuildTarget.Standalone;     ....   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3061\/\">V3061<\/a> Parameter &#8216;namedBuildTarget&#8217; is always rewritten in method body before being used. PlayerSettingsIconsEditor.cs 396<\/p>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u041f\u0440\u0438\u0447\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f <em>if (platformUsesStandardIcons)<\/em>. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434, \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h4>Issue 8<\/h4>\n<pre><code class=\"cs\">internal void BeginNamingNewAsset(....) {   m_State.m_NewAssetIndexInList = m_LocalAssets.IndexOfNewText(....);   if (m_State.m_NewAssetIndexInList != -1)   {     Frame(instanceID, true, false);     GetRenameOverlay().BeginRename(newAssetName, instanceID, 0f);   }   else   {     Debug.LogError(\"Failed to insert new asset into list\");   }    Repaint(); } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;m_State.m_NewAssetIndexInList != -1&#8217; is always true. ObjectListArea.cs 511<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e. <em>m_State.m_NewAssetIndexInList<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <em>IndexOfNewText<\/em>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">public int IndexOfNewText(....) {   int idx = 0;   if (m_ShowNoneItem)     idx++;    for (; idx &lt; m_FilteredHierarchy.results.Length; ++idx)   {     FilteredHierarchy.FilterResult r = m_FilteredHierarchy.results[idx];                          if (foldersFirst &amp;&amp; r.isFolder &amp;&amp; !isCreatingNewFolder)       continue;                          if (foldersFirst &amp;&amp; !r.isFolder &amp;&amp; isCreatingNewFolder)       break;                          string propertyPath = AssetDatabase.GetAssetPath(r.instanceID);     if (EditorUtility.NaturalCompare(....) > 0)     {       return idx;     }   }   return idx; } <\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>idx<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d 0.<\/p>\n<p>\u041a\u0430\u043a \u0438\u0442\u043e\u0433 \u0432\u0435\u0442\u0432\u044c <em>else<\/em> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0448\u0438\u0431\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>IndexOfNewText<\/em>. \u041f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u0438, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c -1.<\/p>\n<h4>Issue 9<\/h4>\n<pre><code class=\"cs\">public static Overlay CreateOverlay(Type type) {   ....   if (overlay == null)   {     Debug.LogWarning(\"Overlay of type {type} can not be instantiated.\" + ....);     return null;   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3138\/\">V3138<\/a> String literal contains potential interpolated expression. Consider inspecting: type. OverlayUtilities.cs 116<\/p>\n<p>PVS-Studio \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0447\u0451\u0442\u044b \u0447\u0430\u0441\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0442. \u043a. \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435\u0442\u043e\u0447\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<h4>Issue 10<\/h4>\n<pre><code class=\"cs\">int GetCurveAtPosition(Vector2 viewPos, out Vector2 closestPointOnCurve) {   ....   for (int i = m_DrawOrder.Count - 1; i >= 0; --i)   {     CurveWrapper wrapper = GetCurveWrapperFromID(m_DrawOrder[i]);      if (wrapper.hidden || wrapper.readOnly || wrapper.curve.length == 0)       continue;     ....   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3080\/\">V3080<\/a> Possible null dereference. Consider inspecting &#8216;wrapper&#8217;. CurveEditor.cs 1889<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u0441\u044b\u043b\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0432\u043d\u043e <em>null<\/em>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <em>GetCurveWrapperFromID<\/em> \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <em>null<\/em>:<\/p>\n<pre><code class=\"cs\">internal CurveWrapper GetCurveWrapperFromID(int curveID) {   if (m_AnimationCurves == null)     return null;    int index;   if (curveIDToIndexMap.TryGetValue(curveID, out index))     return m_AnimationCurves[index];    return null; } <\/code><\/pre>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>wrapper<\/em>. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0441\u044b\u043b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0435\u0447\u044c \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u0432\u044b\u0431\u0440\u043e\u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0432 \u0435\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u0435\u0442\u043e\u0434 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u0435\u0440\u043d\u0451\u0442 <em>null<\/em>, \u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0442\u043e\u0447\u043d\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\n<h4>Issue 11<\/h4>\n<pre><code class=\"cs\">internal static void MaterialShaderReferences(....) {   var material = context.target as Material;   if (material == null || !material.shader)     return;    indexer.AddReference(context.documentIndex, \"shader\", material.shader);    if (!indexer.settings.options.properties)     return;    var ownerPropertyType = typeof(Shader);   var shaderName = $\"{material.shader.name}\/\" ?? string.Empty;   \/\/ &lt;=   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;$&#187;{material.shader.name}\/&#187;&#8216; is always not null. The operator &#8216;??&#8217; is excessive. IndexerExtensions.cs 190<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>$&#187;{material.shader.name}\/&#187;<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0435 <em>null<\/em>. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0441 \u044d\u0442\u0438\u043c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0442\u0440\u0443\u0434\u043d\u043e \u043d\u0435 \u0441\u043e\u0433\u043b\u0430\u0441\u0438\u0442\u044c\u0441\u044f. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 <em>null<\/em> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 &#8216;??&#8217; \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439.<\/p>\n<h4>Issue 12<\/h4>\n<pre><code class=\"cs\">static int CountIntersections(....) {   ....   int hitLength = s_RayCastHits.Length;   float maxDist = 0;   if (hitLength > 0)     maxDist = s_RayCastHits[s_RayCastHits.Length - 1].distance;    physicsScene.Raycast(....);   if (s_RayCastHits.Length > 0)   {     float len = length - s_RayCastHits[0].distance;     if (len > maxDist)     {       maxDist = len;                                 \/\/ &lt;=     }   }    return hitLength + s_RayCastHits.Length; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3137\/\">V3137<\/a> The &#8216;maxDist&#8217; variable is assigned but is not used by the end of the function. TreeAOImporter.cs 142<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043e\u043d\u0430 \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043a\u043e\u0434, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 <em>if (s_RayCastHits.Length > 0)<\/em>, \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e. \u0412\u0441\u0435 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f \u0432 \u044d\u0442\u043e\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h4>Issue 13<\/h4>\n<pre><code class=\"cs\">public override DragAndDropVisualMode DoDrag(....) {   var hierarchyTargetItem = targetItem as GameObjectTreeViewItem;    if (m_CustomDragHandling != null)   {     DragAndDropVisualMode dragResult =        m_CustomDragHandling(parentItem as GameObjectTreeViewItem,                            hierarchyTargetItem,                            ....);     ....   }   DragAndDropVisualMode dragSceneResult =     DoDragScenes(parentItem as GameObjectTreeViewItem,                  hierarchyTargetItem,                  ....);    if (   targetItem != null        &amp;&amp; !IsDropTargetUserModifiable(hierarchyTargetItem, dropPos)) \/\/ &lt;=   {     return DragAndDropVisualMode.Rejected;   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3019\/\">V3019<\/a> Possibly an incorrect variable is compared to null after type conversion using &#8216;as&#8217; keyword. Check variables &#8216;targetItem&#8217;, &#8216;hierarchyTargetItem&#8217;. AssetOrGameObjectTreeViewDragging.cs 153<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e <em>targetItem<\/em> \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c\u0443 \u0442\u0438\u043f\u0443 <em>GameObjectTreeViewItem<\/em> \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>as<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u0441 <em>null<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0442 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443, \u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e.<\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043d\u0435 \u0432\u044b\u0439\u0434\u0435\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <em>as<\/em>, \u0442\u043e\u0433\u0434\u0430 <em>hierarchyTargetItem<\/em> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>null<\/em>. \u0418 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 <em>hierarchyTargetItem<\/em> \u0432 <em>IsDropTargetUserModifiable<\/em> \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u043c\u0438 \u043b\u044e\u0431\u0438\u043c\u043e\u0433\u043e <em>NullReferenceException.<\/em><\/p>\n<p>\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">static bool IsDropTargetUserModifiable(GameObjectTreeViewItem targetItem, ....) {   if (targetItem.isSceneHeader &amp;&amp; !targetItem.scene.isLoaded)     return false;   .... } <\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e <em>hierarchyTargetItem<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u0440\u0430\u043d\u044c\u0448\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0435\u043b\u0435\u0433\u0430\u0442\u0430 <em>m_CustomDragHandling<\/em> \u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <em>DoDragScenes<\/em>. \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043d\u0430 \u043a\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u0435\u043b\u0435\u0433\u0430\u0442 \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>DoDragScenes<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 <em>null<\/em>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442. \u041a\u043e\u0434 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/Unity-Technologies\/UnityCsReference\/blob\/e740821767d2290238ea7954457333f06e952bad\/Editor\/Mono\/GUI\/TreeView\/AssetOrGameObjectTreeViewDragging.cs\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h4>Issue 14<\/h4>\n<pre><code class=\"cs\">static Vector3 ResizeHandlesGUI(....) {   ....   Vector3 scale = Vector3.one;    ....   if (uniformScaling)                                 \/\/ &lt;=   {     float refScale = (xHandle == 1 ? scale.y : scale.x);     scale = Vector3.one * refScale;   }    if (uniformScaling)                                 \/\/ &lt;=   {     float refScale = (xHandle == 1 ? scale.y : scale.x);     scale = Vector3.one * refScale;   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3029\/\">V3029<\/a> The conditional expressions of the &#8216;if&#8217; statements situated alongside each other are identical. Check lines: 722, 728. BuiltinTools.cs 722<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u0440\u0430\u0442\u0438\u043b \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0432\u0430 <em>if<\/em> \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438 \u0438\u0434\u0443\u0442 \u0434\u0440\u0443\u0433 \u0437\u0430 \u0434\u0440\u0443\u0433\u043e\u043c. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0439 <em>if<\/em> \u2013 \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0438\u0448\u043d\u0438\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0438 \u043d\u0430 \u0447\u0442\u043e \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442. \u042d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>refScale<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>scale<\/em>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0442\u043e\u0440\u043e\u0439 \u0431\u043b\u043e\u043a \u0432\u0441\u0451 \u0436\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>uniformScaling<\/em> \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u043e\u0432. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0440\u0430\u0441\u0447\u0451\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0434 \u043e\u0434\u0438\u043d <em>if<\/em>.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u044f \u043d\u0435 \u0437\u0440\u044f \u0440\u0435\u0448\u0438\u043b \u0432\u043d\u043e\u0432\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442. \u041f\u043e\u0432\u0442\u043e\u0440\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 Unity \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043c\u0435\u0441\u0442. \u0427\u0442\u043e \u0438\u0437 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u2013 \u043e\u0448\u0438\u0431\u043a\u0438, \u0430 \u0447\u0442\u043e \u2013 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438? \u0421\u0443\u0434\u0438\u0442\u044c \u043e\u0431 \u044d\u0442\u043e\u043c \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c. \u0421\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u0443\u0432\u044b, \u0431\u044b\u0432\u0430\u0435\u0442, \u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0446\u0435\u043d\u0438\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0412 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 Unity \u0437\u0430 \u0438\u0445 \u0442\u0440\u0443\u0434! \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0433\u043b\u0430 \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c PVS-Studio. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u043a\u043b\u044e\u0447\u0438\u043a \u0443 \u043d\u0430\u0441 \u043d\u0430 <a href=\"https:\/\/pvs-studio.com\/pvs-studio\/try-free\/?utm_source=habr&amp;utm_medium=articles&amp;utm_content=unity&amp;utm_term=link_try_free\">\u0441\u0430\u0439\u0442\u0435<\/a>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Artem Rovenskii. <a href=\"https:\/\/pvs-studio.com\/en\/blog\/posts\/csharp\/0932\/\">PVS-Studio static analyzer to recheck Unity<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/659885\/\"> https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/659885\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Unity \u2013 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0445 \u0434\u0432\u0438\u0436\u043a\u043e\u0432. \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0436\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0421 \u043d\u0430\u0448\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0448\u043b\u043e \u043f\u043e\u0447\u0442\u0438 4 \u0433\u043e\u0434\u0430. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0420\u0430\u043d\u0435\u0435 \u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u043b\u0438 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0568\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043f\u0440\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 Unity. \u0414\u0443\u043c\u0430\u044e, \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0439. \u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u044b\u0441\u044f\u0447\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u044f\u0442 \u0441\u0432\u043e\u0451 \u0432\u0440\u0435\u043c\u044f \u0432 \u0438\u0433\u0440\u0430\u0445, \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Unity. \u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u044b \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0434\u043e\u043b\u0433\u043e \u0431\u0435\u0437 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f, \u0432\u0435\u0434\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u043d\u0438\u0445 \u043c\u043e\u0433\u0443\u0442 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043b\u044e\u0434\u0435\u0439.<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u0432\u0438\u0436\u043a\u0430 Unity \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"https:\/\/github.com\/Unity-Technologies\/UnityCsReference\/tree\/98cc8a97afc8cb990bc0c89165bdb276cbcc8ec4\">2022.1.0b8<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/h3>\n<h4>Issue 1<\/h4>\n<pre><code class=\"cs\">private void Draw(Rect windowRect) {   var rect = new Rect(....);   ....   if (m_NumFilteredVariants > 0)   {     ....             if (m_NumFilteredVariants > maxFilteredLength)     {       GUI.Label(....);       rect.y += rect.height;     }   }   else   {     GUI.Label(rect, \"No variants with these keywords\");     rect.y += rect.height;                               \/\/ &lt;=   }    rect.y = windowRect.height - kMargin - kSpaceHeight \u2013      EditorGUI.kSingleLineHeight;                         \/\/ &lt;=   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3008\/\">V3008<\/a> The &#8216;rect.y&#8217; variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 370, 366. ShaderVariantCollectionInspector.cs 370<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>rect.y<\/em> \u0434\u0432\u0430\u0436\u0434\u044b \u043f\u043e\u0434\u0440\u044f\u0434 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u043d\u0438\u044f\u043c\u0438 \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0443\u0442\u044c \u0432\u044b\u0448\u0435 \u043f\u043e\u0434 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u043c <em>m_NumFilteredVariants > maxFilteredLength<\/em> \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u0440\u044f\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e, \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u043c\u044b\u0441\u043b\u0430.<\/p>\n<h4>Issue 2<\/h4>\n<pre><code class=\"cs\">public static string FetchBuiltinDescription(....) {   return string.IsNullOrEmpty(version?.packageInfo?.description) ?     string.Format(L10n.Tr(....), version.displayName) :     version.packageInfo.description.Split(....)[0]; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3042\/\">V3042<\/a> Possible NullReferenceException. The &#8216;?.&#8217; and &#8216;.&#8217; operators are used for accessing members of the &#8216;version&#8217; object UpmPackageDocs.cs 38<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0434\u0432\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0447\u043b\u0435\u043d\u0430\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>version<\/em> \u0431\u0443\u0434\u0435\u0442 <em>null<\/em>, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 <em>IsNullOrEmpty<\/em> \u0432\u0435\u0440\u043d\u0451\u0442 <em>true,<\/em> \u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a <em>displayName<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em>.<\/p>\n<h4>Issue 3<\/h4>\n<pre><code class=\"cs\">public void SetScaleFocused(Vector2 focalPoint,                             Vector2 newScale,                             bool lockHorizontal,                             bool lockVertical) {   if (uniformScale)     lockHorizontal = lockVertical = false;   else   {     if (hZoomLockedByDefault)       lockHorizontal = !lockHorizontal;      if (hZoomLockedByDefault)       lockVertical = !lockVertical;   } .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3029\/\">V3029<\/a> The conditional expressions of the &#8216;if&#8217; statements situated alongside each other are identical. Check lines: 930, 933. ZoomableArea.cs 930<\/p>\n<p>\u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u043f\u043e\u0434\u0440\u044f\u0434. *<em>hZoomLockedByDefault<\/em> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043c\u0435\u0441\u0442\u043e \u0435\u0433\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0440\u044f\u0434\u043e\u043c \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <em>vZoomLockedByDefault<\/em>.<\/p>\n<pre><code class=\"cs\">internal class ZoomableArea {   ....   \/\/ Zoom lock settings   public bool hZoomLockedByDefault = false;   public bool vZoomLockedByDefault = false;   .... } <\/code><\/pre>\n<p>\u0412\u0441\u0451 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0435\u0447\u0430\u0442\u043a\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440.<\/p>\n<h4>Issue 4<\/h4>\n<pre><code class=\"cs\">private void UpdateTextFieldVisibility() {   if (showInputField)   {     ....   }   else if (inputTextField != null &amp;&amp; inputTextField.panel != null)   {     if (inputTextField.panel != null)                         \/\/ &lt;=       inputTextField.RemoveFromHierarchy();      inputTextField.UnregisterValueChangedCallback(OnTextFieldValueChange);     inputTextField.UnregisterCallback&lt;FocusOutEvent>(OnTextFieldFocusOut);     inputTextField = null;   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;inputTextField.panel != null&#8217; is always true. BaseSlider.cs 648<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 <em>inputTextField.panel != null<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e.<\/p>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0430\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u0448\u0435 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u0443\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0445\u043e\u0442\u0435\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435, \u043d\u043e \u043e\u0448\u0438\u0431\u043b\u0438\u0441\u044c.<\/p>\n<h4>Issue 5<\/h4>\n<p>\u0411\u044b\u043b \u043d\u0430\u0439\u0434\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cs\">public enum EventType {   ....   \/\/ Mouse button was released.   MouseUp = 1,   ....   \/\/ Already processed event.   Used = 12,   .... } public static void MinMaxScroller(....) {   ....   if (   Event.current.type == EventType.MouseUp        &amp;&amp; Event.current.type == EventType.Used)    {     scrollControlID = 0;   }    .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression is always false. Probably the &#8216;||&#8217; operator should be used here. EditorGUIExt.cs 141<\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0430\u0448\u0451\u043b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043b\u043e\u0436\u043d\u043e. \u041a\u0430\u043a\u043e\u0435 \u0431\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0438 \u0432\u0435\u0440\u043d\u0443\u043b\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e, \u043e\u0434\u043d\u043e \u0438\u0437 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0436\u043d\u043e.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">public static void MinMaxScroller(....) {   ....   if (   Event.current.type == EventType.MouseUp        || Event.current.type == EventType.Used)    {     scrollControlID = 0;   }   .... } <\/code><\/pre>\n<h4>Issue 6<\/h4>\n<pre><code class=\"cs\">private List&lt;T> GetChildrenRecursively(....) {   if (result == null)     result = new List&lt;T>();   if (m_Children.Any())   {     var children = sorted ? (....)m_Children.OrderBy(c => c.key)                                             .OrderBy(c => c.m_Priority)                            : m_Children;     foreach (var child in children)       child.GetChildrenRecursively(sorted, result);   }   else if (value != null)     result.Add(value);   return result; } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3078\/\">V3078<\/a> Original sorting order will be lost after repetitive call to &#8216;OrderBy&#8217; method. Use &#8216;ThenBy&#8217; method to preserve the original sorting. MenuService.cs 499<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432 \u043a\u043e\u0434\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \u0434\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <em>OrderBy<\/em>.<\/p>\n<p>\u041a\u0430\u043a \u043f\u043e \u043c\u043d\u0435, \u0442\u0430\u043a \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0434\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <em>OrderBy<\/em> \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u043c \u043e\u0448\u0438\u0431\u043a\u0438. \u042d\u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0448\u0438\u0431\u043a\u0435, \u0435\u0441\u043b\u0438 \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0445\u043e\u0442\u0435\u043b \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e \u043a\u043b\u044e\u0447\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0443, \u0442\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430. \u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0434\u0432\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 <em>OrderBy<\/em> \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0443, \u0430 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443. \u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e <em>OrderBy<\/em> \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <em>ThenBy<\/em>, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0430\u0441\u044c \u043d\u0435 &#171;\u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442&#187;. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441 <em>ThenBy<\/em> \u0431\u0443\u0434\u0435\u0442 \u043b\u0443\u0447\u0448\u0435 \u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432. \u0417\u0430 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0430\u043c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0928\/\">\u0437\u0430\u043c\u0435\u0442\u043a\u0435<\/a>.<\/p>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, PVS-Studio \u043d\u0430\u0448\u0451\u043b \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u043f\u043e\u0434\u043e\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e: <a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3078\/\">V3078<\/a> Original sorting order will be lost after repetitive call to &#8216;OrderBy&#8217; method. Use &#8216;ThenBy&#8217; method to preserve the original sorting. SearchSelector.cs 177<\/p>\n<h4>Issue 7<\/h4>\n<pre><code class=\"cs\">public void IconSectionGUI(NamedBuildTarget namedBuildTarget,....) {   ....   if (platformUsesStandardIcons)   {     var selectedDefault = (m_SelectedPlatform &lt; 0);     \/\/ Set default platform variables     BuildPlatform platform = null;     namedBuildTarget = NamedBuildTarget.Standalone;     ....   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3061\/\">V3061<\/a> Parameter &#8216;namedBuildTarget&#8217; is always rewritten in method body before being used. PlayerSettingsIconsEditor.cs 396<\/p>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u041f\u0440\u0438\u0447\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f <em>if (platformUsesStandardIcons)<\/em>. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434, \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h4>Issue 8<\/h4>\n<pre><code class=\"cs\">internal void BeginNamingNewAsset(....) {   m_State.m_NewAssetIndexInList = m_LocalAssets.IndexOfNewText(....);   if (m_State.m_NewAssetIndexInList != -1)   {     Frame(instanceID, true, false);     GetRenameOverlay().BeginRename(newAssetName, instanceID, 0f);   }   else   {     Debug.LogError(\"Failed to insert new asset into list\");   }    Repaint(); } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;m_State.m_NewAssetIndexInList != -1&#8217; is always true. ObjectListArea.cs 511<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u0442\u0438\u043d\u043d\u043e. <em>m_State.m_NewAssetIndexInList<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <em>IndexOfNewText<\/em>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"cs\">public int IndexOfNewText(....) {   int idx = 0;   if (m_ShowNoneItem)     idx++;    for (; idx &lt; m_FilteredHierarchy.results.Length; ++idx)   {     FilteredHierarchy.FilterResult r = m_FilteredHierarchy.results[idx];                          if (foldersFirst &amp;&amp; r.isFolder &amp;&amp; !isCreatingNewFolder)       continue;                          if (foldersFirst &amp;&amp; !r.isFolder &amp;&amp; isCreatingNewFolder)       break;                          string propertyPath = AssetDatabase.GetAssetPath(r.instanceID);     if (EditorUtility.NaturalCompare(....) > 0)     {       return idx;     }   }   return idx; } <\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <em>idx<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d 0.<\/p>\n<p>\u041a\u0430\u043a \u0438\u0442\u043e\u0433 \u0432\u0435\u0442\u0432\u044c <em>else<\/em> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043e\u0448\u0438\u0431\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>IndexOfNewText<\/em>. \u041f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u0438, \u0447\u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c -1.<\/p>\n<h4>Issue 9<\/h4>\n<pre><code class=\"cs\">public static Overlay CreateOverlay(Type type) {   ....   if (overlay == null)   {     Debug.LogWarning(\"Overlay of type {type} can not be instantiated.\" + ....);     return null;   }   .... } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3138\/\">V3138<\/a> String literal contains potential interpolated expression. Consider inspecting: type. OverlayUtilities.cs 116<\/p>\n<p>PVS-Studio \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0449\u0435\u043d \u0441\u0438\u043c\u0432\u043e\u043b \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043d\u0435\u0434\u043e\u0447\u0451\u0442\u044b \u0447\u0430\u0441\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0442 \u043f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0442. \u043a. \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435\u0442\u043e\u0447\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e.<\/p>\n<h4>Issue 10<\/h4>\n<pre><code class=\"cs\">int GetCurveAtPosition(Vector2 viewPos, out Vector2 closestPointOnCurve) {   ....   for (int i = m_DrawOrder.Count - 1; i >= 0; --i)   {     CurveWrapper wrapper = GetCurveWrapperFromID(m_DrawOrder[i]);      if (wrapper.hidden || wrapper.readOnly || wrapper.curve.length == 0)       continue;     ....   } } <\/code><\/pre>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3080\/\">V3080<\/a> Possible null dereference. Consider inspecting &#8216;wrapper&#8217;. CurveEditor.cs 1889<\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0440\u0430\u0437\u044b\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044e \u0441\u0441\u044b\u043b\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0432\u043d\u043e <em>null<\/em>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <em>GetCurveWrapperFromID<\/em> \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <em>null<\/em>:<\/p>\n<pre><code class=\"cs\">i<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331690","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331690"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331690\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}