Exemplo n.º 1
0
        private static void AddRulesForSelection(BuildRules rules, string searchPattern)
        {
            var isDir = rules.searchPatternDir.Equals(searchPattern);

            foreach (var item in Selection.objects)
            {
                var path = AssetDatabase.GetAssetPath(item);
                var rule = new BuildRule();
                rule.searchPath    = path;
                rule.searchPattern = searchPattern;
                rule.searchOption  = SearchOption.AllDirectories;
                rule.unshared      = false;
                rule.searchDirOnly = isDir;
                ArrayUtility.Add <BuildRule>(ref rules.rules, rule);
            }
            EditorUtility.SetDirty(rules);
            AssetDatabase.SaveAssets();
            Selection.activeObject = rules;
            EditorUtility.FocusProjectWindow();
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            BuildRules rules = target as BuildRules;

            EditorGUILayout.HelpBox("【操作提示】" +
                                    "\n    - 编辑器菜单中 Assets/Apply Rule 可以针对 Project 视图中选中的文件夹快速创建目标规则:" +
                                    "\n     - Text:" + rules.searchPatternText +
                                    "\n     - Prefab" + rules.searchPatternPrefab +
                                    "\n     - PNG" + rules.searchPatternPNG +
                                    "\n     - Material" + rules.searchPatternMaterial +
                                    "\n     - Controller" + rules.searchPatternController +
                                    "\n     - Asset" + rules.searchPatternAsset +
                                    "\n     - Scene" + rules.searchPatternScene +
                                    "\n【注意事项】:" +
                                    "\n    - 所有shader放到一个包" +
                                    "\n    - 场景文件不可以和非场景文件放到一个包" +
                                    "\n    - 预知体通常单个文件一个包" +
                                    "\n    - 资源冗余可以自行集成 AssetBundle-Browser 查看" +
                                    "\n作者:fjy" +
                                    "\n邮箱:[email protected]", MessageType.None);

            using (var h = new EditorGUILayout.HorizontalScope())
            {
                GUILayout.Space(16);
                if (GUILayout.Button("清理"))
                {
                    if (EditorUtility.DisplayDialog("提示", "是否确定清理?", "确定"))
                    {
                        rules.rules = new BuildRule[0];
                    }
                }

                if (GUILayout.Button("执行"))
                {
                    rules.Apply();
                }
                GUILayout.Space(16);
            }
            base.OnInspectorGUI();
        }