Exemplo n.º 1
0
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
        {
            if(importedAssets.Length <= 0) { return; }
            if(Holder == null) { Holder = Getters4Editor.GetHolder(); }

            var md = Holder.metadatas;
            if(md.validity == Validater.invalidate) { return; }

            foreach(var path in importedAssets) {
                var file = Path.GetFileName(path);
                if(file.StartsWith("_")) { return; }

                var extension = Path.GetExtension(path);
                var template = md.templates.FirstOrDefault(e => e.Extension == extension);
                if(template == null || template.validity == Validater.invalidate) { return; }

                var importer = AssetImporter.GetAtPath(path);
                if(importer == null) { continue; }

                var labels = AssetDatabase.GetLabels(importer).ToList();
                if(labels.Contains(template.label)) { continue; }

                if(template.ignores.Any(ig => path.Contains(ig)) || !template.considers.Any(co => path.Contains(co))) { continue; }

                Custom(path, template);

                labels.Add(template.label);
                AssetDatabase.SetLabels(importer, labels.ToArray());
                AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
            }

            AssetDatabase.Refresh();
        }
Exemplo n.º 2
0
        public static Object GetExecutorFunctionsObject(MetadataHolder holder = null)
        {
            if(ExecutorFunctionsObject == null) {
                var path = GetExecutorFunctionsPath(holder);
                ExecutorFunctionsObject = AssetDatabase.LoadAssetAtPath(path, typeof(TextAsset));
            }

            return ExecutorFunctionsObject;
        }
Exemplo n.º 3
0
 public static string GetFilePath(MetadataHolder holder)
 {
     var root = AssetDatabase.GetAssetPath(MonoScript.FromMonoBehaviour(holder));
     return root.Substring(0, root.IndexOf(PROJECT_NAME) + PROJECT_NAME.Length) + "/" + FILE_NAME;
 }
Exemplo n.º 4
0
 public static string GetExecutorFunctionsPath(MetadataHolder holder = null)
 {
     var path = GetFilePath(holder == null ? GetHolder() : holder);
     return path.TrimEnd(FILE_NAME.ToCharArray()) + EXECUTOR_FUNCTIONS_SCRIPT_PATH;
 }