Esempio n. 1
0
        private void DrawMoreButton(GameObjectIssueRecord record)
        {
            if (!UIHelpers.RecordButton(record, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                return;
            }

            GenericMenu menu = new GenericMenu();

            if (!string.IsNullOrEmpty(record.path))
            {
                menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                {
                    if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, record.path))
                    {
                        MaintainerWindow.ShowNotification("Ignore added: " + record.path);
                        IssuesFiltersWindow.Refresh();
                    }
                    else
                    {
                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                    }
                });

                DirectoryInfo dir = Directory.GetParent(record.path);
                if (dir.Name != "Assets")
                {
                    menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                    {
                        if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, dir.ToString()))
                        {
                            MaintainerWindow.ShowNotification("Ignore added: " + dir);
                            IssuesFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                        }
                    });
                }
            }

            if (!string.IsNullOrEmpty(record.componentName))
            {
                menu.AddItem(new GUIContent("Ignore/Add component to ignores"), false, () =>
                {
                    if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.componentIgnores, record.componentName))
                    {
                        MaintainerWindow.ShowNotification("Ignore added: " + record.componentName);
                        IssuesFiltersWindow.Refresh();
                    }
                    else
                    {
                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                    }
                });
            }
            menu.ShowAsContext();
        }
 public void TryDetectIssue(RecordLocation location, string assetPath, GameObject target, Type componentType, string componentName, int orderIndex)
 {
     foreach (var duplicateInfo in existingData)
     {
         if (duplicateInfo.hash == newHash)
         {
             var issue = GameObjectIssueRecord.Create(IssueKind.DuplicateComponent, location,
                                                      assetPath, target, componentType, componentName, orderIndex);
             issues.Add(issue);
             break;
         }
     }
 }
        public void TryDetectIssue(RecordLocation location, string assetPath, GameObject target)
        {
#if UNITY_2019_1_OR_NEWER
            missingComponentsCount = GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(target);
#endif
            if (missingComponentsCount <= 0 || !enabled)
            {
                return;
            }

            var record = GameObjectIssueRecord.Create(IssueKind.MissingComponent, location, assetPath, target, null, null, -1);
            record.headerFormatArgument = missingComponentsCount;
            issues.Add(record);
        }
        public bool TryDetectIssue(RecordLocation location, string assetPath, GameObject target)
        {
            if (!CSPrefabTools.IsMissingPrefabInstance(target))
            {
                return(false);
            }

            if (enabled)
            {
                issues.Add(GameObjectIssueRecord.Create(IssueKind.MissingPrefab, location, assetPath, target));
            }

            return(true);
        }
Esempio n. 5
0
        public void TryDetectIssue(RecordLocation location, string assetPath, GameObject target)
        {
            if (!enabled)
            {
                return;
            }

            if (IsTransformHasHugePosition(target.transform))
            {
                var record = GameObjectIssueRecord.Create(IssueKind.HugePosition, location, assetPath, target,
                                                          CSReflectionTools.transformType, "Transform", 0, "Position");
                issues.Add(record);
            }
        }
        private void AddIssue(RecordLocation location, string assetPath, GameObject target, Type componentType, string componentName, int orderIndex, string propertyPath)
        {
            IssueRecord record;

            if (location != RecordLocation.Asset)
            {
                record = GameObjectIssueRecord.Create(IssueKind.MissingReference, location, assetPath, target, componentType, componentName, orderIndex, propertyPath);
            }
            else
            {
                record = ScriptableObjectIssueRecord.Create(IssueKind.MissingReference, assetPath, componentName, propertyPath);
            }

            issues.Add(record);
        }
Esempio n. 7
0
        private void DrawRecordButtons(IssueRecord record, int recordIndex)
        {
            DrawShowButtonIfPossible(record);
            DrawFixButton(record, recordIndex);

            if (!record.compactMode)
            {
                DrawCopyButton(record);
                DrawHideButton(record, recordIndex);
            }

            GameObjectIssueRecord objectIssue = record as GameObjectIssueRecord;

            if (objectIssue != null)
            {
                DrawMoreButton(objectIssue);
            }
        }
        public void TryDetectIssue(RecordLocation currentLocation, string assetPath, GameObject target)
        {
            if (!enabled)
            {
                return;
            }

            if (terrainChecked && terrainColliderChecked && terrainColliderTerrainData != terrainTerrainData)
            {
                issues.Add(GameObjectIssueRecord.Create(IssueKind.InconsistentTerrainData, currentLocation, assetPath, target, componentType, componentName, componentIndex));
            }

            terrainChecked         = false;
            terrainColliderChecked = false;

            terrainTerrainData         = null;
            terrainColliderTerrainData = null;
        }
        public void TryDetectIssue(RecordLocation location, string assetPath, GameObject target)
        {
            if (!enabled)
            {
                return;
            }

            var layerIndex = target.layer;

            if (!string.IsNullOrEmpty(LayerMask.LayerToName(layerIndex)))
            {
                return;
            }

            var issue = GameObjectIssueRecord.Create(IssueKind.UnnamedLayer, location, assetPath, target);

            issue.headerExtra = "(index: " + layerIndex + ")";
            issues.Add(issue);
        }
Esempio n. 10
0
        protected override void DrawRecord(int recordIndex, out bool recordRemoved)
        {
            recordRemoved = false;
            RecordBase record = records[recordIndex];

            UIHelpers.Separator();

            using (UIHelpers.Horizontal())
            {
                DrawSeverityIcon(record);
                if (record.location == RecordLocation.Prefab)
                {
                    UIHelpers.DrawPrefabIcon();
                }
                GUILayout.Label(record.GetHeader(), UIHelpers.richLabel, GUILayout.ExpandWidth(false));
            }

            GUILayout.Label(record.GetBody(), UIHelpers.richLabel);

            using (UIHelpers.Horizontal(UIHelpers.panelWithBackground))
            {
                AddShowButtonIfPossible(record);

                if (GUILayout.Button(new GUIContent("Copy", "Copies record text to the clipboard."), UIHelpers.recordButton))
                {
                    EditorGUIUtility.systemCopyBuffer = record.ToString(true);
                    MaintainerWindow.ShowNotification("Issue record copied to clipboard!");
                }

                if (GUILayout.Button(new GUIContent("Hide", "Hide this issue from the results list.\nUseful when you fixed issue and wish to hide it away."), UIHelpers.recordButton))
                {
                    // ReSharper disable once CoVariantArrayConversion
                    records = CSArrayTools.RemoveAt(records as IssueRecord[], recordIndex);
                    SearchResultsStorage.IssuesSearchResults = (IssueRecord[])records;
                    recordRemoved = true;
                    return;
                }

                //UIHelpers.VerticalSeparator();
                GameObjectIssueRecord objectIssue = record as GameObjectIssueRecord;
                if (objectIssue != null)
                {
                    if (GUILayout.Button("More ...", UIHelpers.recordButton))
                    {
                        GenericMenu menu = new GenericMenu();
                        if (!string.IsNullOrEmpty(objectIssue.path))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, objectIssue.path))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.path);
                                    IssuesIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });

                            DirectoryInfo dir = Directory.GetParent(objectIssue.path);
                            if (dir.Name != "Assets")
                            {
                                menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                                {
                                    if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, dir.ToString()))
                                    {
                                        MaintainerSettings.Save();
                                        MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                        IssuesIgnoresWindow.Refresh();
                                    }
                                    else
                                    {
                                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                    }
                                });
                            }
                        }

                        if (!string.IsNullOrEmpty(objectIssue.component))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add component to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.componentIgnores, objectIssue.component))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.component);
                                    IssuesIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });
                        }
                        menu.ShowAsContext();
                    }
                }
            }
        }