예제 #1
0
        private void RefreshConfigs()
        {
            checkerFileInfos = CheckerUtility.ReadCheckerFileInfos();

            selectedCheckerFileInfo = null;
            checkerDrawer           = null;

            if (configListView != null)
            {
                configListView.Clear();
            }
            else
            {
                configListView = new EasyListView();
                configListView.HeaderContent    = "Checker File List";
                configListView.OnSelectedChange = (selected) =>
                {
                    SetSelected((CheckerFileInfo)selected);
                };
            }
            foreach (var cfi in checkerFileInfos)
            {
                configListView.AddItem(Path.GetFileNameWithoutExtension(cfi.filePath), cfi);
            }
        }
예제 #2
0
 private void SaveSelectedCheckerFile()
 {
     if (selectedCheckerFileInfo != null)
     {
         CheckerUtility.SaveCheckerFileInfo(selectedCheckerFileInfo);
     }
     timeSinceStartup = EditorApplication.timeSinceStartup;
 }
예제 #3
0
        static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            List <CheckerFileInfo> checkerFiles = CheckerUtility.ReadCheckerFileInfos();
            CheckerResultInfo      resultInfo   = CheckerUtility.ReadCheckerResultInfo();

            if (importedAssets != null && importedAssets.Length > 0)
            {
                foreach (var assetPath in importedAssets)
                {
                    if (AssetDatabase.IsValidFolder(assetPath) && !CheckerUtility.ReadSetting().isFolderAsAsset)
                    {
                        continue;
                    }

                    CheckerFileInfo cfi = checkerFiles.FirstOrDefault((cFileInfo) =>
                    {
                        return(cFileInfo.checker.enable && cFileInfo.checker.IsMatch(assetPath));
                    });

                    if (cfi == null)
                    {
                        resultInfo.AddPassedResult(assetPath);
                    }
                    else
                    {
                        Checker checker   = cfi.checker;
                        int     errorCode = 0;
                        if (checker.DoAnalyse(assetPath, ref errorCode))
                        {
                            checker.DoOperate(assetPath);

                            resultInfo.RemoveAsset(assetPath);
                        }
                        else
                        {
                            resultInfo.AddFailedResult(assetPath, errorCode);
                        }
                    }
                }
            }

            if (deletedAssets != null && deletedAssets.Length > 0)
            {
                foreach (var assetPath in deletedAssets)
                {
                    resultInfo.RemoveAsset(assetPath);
                }
            }

            CheckerUtility.SaveCheckerResultInfo();
        }
예제 #4
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.BeginArea(rect);
            {
                EditorGUILayout.BeginVertical();
                {
                    EGUILayout.DrawBoxHeader("Setting", EGUIStyles.BoxedHeaderCenterStyle, GUILayout.ExpandWidth(true));
                    EditorGUILayout.Space();

                    CheckerSetting setting = CheckerUtility.ReadSetting();
                    setting.isFolderAsAsset = EditorGUILayout.Toggle("Is Asset For Folder", setting.isFolderAsAsset);

                    GUILayout.FlexibleSpace();


                    if (GUILayout.Button("Close"))
                    {
                        Window.CloseWindow();
                    }
                }
                EditorGUILayout.EndVertical();
            }
            GUILayout.EndArea();
        }
예제 #5
0
        private void DrawToolbar()
        {
            if (toolbarDrawer == null)
            {
                toolbarDrawer = new ToolbarDrawer()
                {
                    LeftDrawable = new HorizontalLayoutDrawer
                                   (
                        new ToolbarButtonDrawer()
                    {
                        Text      = Contents.refreshContent,
                        OnClicked = () =>
                        {
                            RefreshConfigs();
                            Repaint();
                        }
                    },
                        new ToolbarButtonDrawer()
                    {
                        Text      = Contents.createContent,
                        OnClicked = () =>
                        {
                            string filePath = EditorUtility.SaveFilePanel("Save", CheckerUtility.CHECKER_CONFIG_DIR, "asset_checker", "json");
                            if (!string.IsNullOrEmpty(filePath))
                            {
                                filePath            = filePath.Replace("\\", "/");
                                CheckerFileInfo cfi = new CheckerFileInfo()
                                {
                                    filePath = filePath,
                                    checker  = new Checker(),
                                };

                                CheckerUtility.SaveCheckerFileInfo(cfi);
                                RefreshConfigs();

                                configListView.SelectedItem = cfi;
                                SetSelected(cfi);

                                Repaint();
                            }
                        }
                    },
                        new ToolbarButtonDrawer()
                    {
                        Text      = Contents.saveContent,
                        OnClicked = () =>
                        {
                            SaveSelectedCheckerFile();
                        },
                    },
                        new ToolbarButtonDrawer()
                    {
                        Text      = Contents.deleteContent,
                        OnClicked = () =>
                        {
                            if (selectedCheckerFileInfo != null)
                            {
                                CheckerUtility.DeleteCheckerFileInfo(selectedCheckerFileInfo);
                            }
                            RefreshConfigs();
                            Repaint();
                        }
                    }
                                   ),
                    RightDrawable = new HorizontalLayoutDrawer
                                    (
                        new ToolbarToggleDrawer()
                    {
                        Text           = Contents.autoSaveContent,
                        LabelWidth     = 60.0f,
                        Value          = isAutoSave,
                        OnValueChanged = (result) =>
                        {
                            isAutoSave = result;
                        }
                    },
                        new PopupDrawer <int>()
                    {
                        Width      = 60,
                        EnableFunc = () =>
                        {
                            return(isAutoSave);
                        },
                        Contents       = saveIntervalContents,
                        Values         = saveIntervalValues,
                        Value          = saveInterval,
                        OnValueChanged = (value) =>
                        {
                            saveInterval = value;
                        }
                    }, new ToolbarButtonDrawer()
                    {
                        Text      = Contents.settingContent,
                        OnClicked = () =>
                        {
                            var pos = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                            CheckerSettingPopupContent.ShowWin(pos);
                        }
                    }
                                    ),
                };
            }
            toolbarDrawer.OnGUILayout();
        }