// ================================================================================
        //  unity methods
        // --------------------------------------------------------------------------------

        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
        {
            // skip automatic import on opening a project since this might create a few unexpected issues, including broken preview images
            if (!_editorIsInUserMode)
            {
                return;
            }

            AnimationImporter importer = AnimationImporter.Instance;

            if (importer == null)
            {
                return;
            }

            // Do not create shared config during AssetPostprocess, or else it will recreate an empty config
            importer.LoadUserConfig();

            // If no config exists, they can't have set up automatic importing so just return out.
            if (importer.sharedData == null)
            {
                return;
            }

            if (importer.sharedData.automaticImporting)
            {
                List <string> markedAssets = new List <string>();

                foreach (string asset in importedAssets)
                {
                    if (AnimationImporter.IsValidAsset(asset))
                    {
                        MarkAssetForImport(asset, markedAssets);
                    }
                }

                if (markedAssets.Count > 0)
                {
                    _assetsMarkedForImport.Clear();
                    _assetsMarkedForImport.AddRange(markedAssets);

                    if (_importDelegate == null)
                    {
                        _importDelegate = new EditorApplication.CallbackFunction(ImportAssets);
                    }

                    // Subscribe to callback
                    EditorApplication.update = Delegate.Combine(EditorApplication.update, _importDelegate) as EditorApplication.CallbackFunction;
                }
            }
        }
Esempio n. 2
0
        // ================================================================================
        //  unity methods
        // --------------------------------------------------------------------------------

        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
        {
            AnimationImporter importer = AnimationImporter.Instance;

            if (importer == null)
            {
                return;
            }

            // Do not create shared config during AssetPostprocess, or else it will recreate an empty config
            importer.LoadUserConfig();

            // If no config exists, they can't have set up automatic importing so just return out.
            if (importer.SharedData == null)
            {
                return;
            }

            if (importer.SharedData.AutomaticImporting)
            {
                List <string> markedAssets = new List <string>();

                foreach (string asset in importedAssets)
                {
                    if (AnimationImporter.IsValidAsset(asset))
                    {
                        MarkAssetForImport(asset, markedAssets);
                    }
                }

                if (markedAssets.Count > 0)
                {
                    assetsMarkedForImport.Clear();
                    assetsMarkedForImport.AddRange(markedAssets);

                    if (importDelegate == null)
                    {
                        importDelegate = new EditorApplication.CallbackFunction(ImportAssets);
                    }

                    // Subscribe to callback
                    EditorApplication.update = Delegate.Combine(EditorApplication.update, importDelegate) as EditorApplication.CallbackFunction;
                }
            }
        }