Ejemplo n.º 1
0
        static void DoImport(DefaultAsset[] assets)
        {
            foreach (var asset in assets)
            {
                var settings = ImportSettingsReference.LoadImportSettings(asset);
                if (!settings)
                {
                    CreateSettingsThenImport(assets);
                    return;
                }
            }

            foreach (var asset in assets)
            {
                var reference = ImportSettingsReference.LoadImportSettings(asset);
                if (reference)
                {
                    ASEImporter.Import(asset, reference.settings);
                }
                else
                {
                    Debug.LogWarning("File " + asset.name + " has empty import settings, it is ignored.");
                }
            }
        }
Ejemplo n.º 2
0
 static void ClearAssetSettings()
 {
     GetSelectedAseprites()
     .Select(it => ImportSettingsReference.GetImportSettingsPath(it))
     .ToList()
     .ForEach(it => AssetDatabase.DeleteAsset(it));
 }
Ejemplo n.º 3
0
            public void _Init(DefaultAsset[] selectedAssets)
            {
                selectedAssets.ForEach(x => m_Paths.Add(AssetDatabase.GetAssetPath(x)));
                var asepritesPath = m_Paths[0];
                var import        = AssetImporter.GetAtPath(asepritesPath);
                var importData    = JsonUtility.FromJson <MetaSpriteImportData>(import.userData);

                m_Reference = CreateInstance <ImportSettingsReference>();
                if (importData != null)
                {
                    var settingsPath = AssetDatabase.GUIDToAssetPath(importData.metaSpriteSettingsGuid);
                    m_Reference.ImporterSettings = AssetDatabase.LoadAssetAtPath <ImportSettings>(settingsPath);
                }
                m_Editor = Editor.CreateEditor(m_Reference);
                AssetDatabase.SaveAssets();
            }
Ejemplo n.º 4
0
 private static void CompleteAutoImports()
 {
     EditorApplication.update = Delegate.Remove(EditorApplication.update, _importDelegate as EditorApplication.CallbackFunction) as EditorApplication.CallbackFunction;
     AssetDatabase.Refresh();
     ASEImporter.Refresh();
     foreach (var path in _autoImports)
     {
         var asset     = AssetDatabase.LoadAssetAtPath <DefaultAsset>(path);
         var reference = ImportSettingsReference.LoadImportSettings(asset);
         if (reference?.settings && reference.settings.automaticReimport)
         {
             ASEImporter.Import(asset, reference.settings);
         }
     }
     _autoImports.Clear();
 }
Ejemplo n.º 5
0
        static void CreateSettingsThenImport(DefaultAsset[] assets)
        {
            var size   = new Vector2(Screen.width, Screen.height);
            var rect   = new Rect(size.x / 2, size.y / 2, 250, 200);
            var window = (CreateSettingsWindow)EditorWindow.CreateInstance(typeof(CreateSettingsWindow));

            window.position = rect;

            var paths = assets.Select(it => ImportSettingsReference.GetImportSettingsPath(it)).ToList();

            window._Init(paths, settings => { foreach (var asset in assets)
                                              {
                                                  ASEImporter.Import(asset, settings);
                                              }
                         });

            window.ShowPopup();
        }
Ejemplo n.º 6
0
        static void EditAssetSettings()
        {
            var aseprites = GetSelectedAseprites();
            var path      = ImportSettingsReference.GetImportSettingsPath(aseprites[0]);
            var ret       = (ImportSettingsReference)AssetDatabase.LoadAssetAtPath(path, typeof(ImportSettingsReference));

            if (ret == null)
            {
                ret = ScriptableObject.CreateInstance <ImportSettingsReference>();
                AssetDatabase.CreateAsset(ret, path);
            }

            var size   = new Vector2(Screen.width, Screen.height);
            var rect   = new Rect(size.x / 2, size.y / 2, 250, 200);
            var window = (InspectSettingsWindow)EditorWindow.CreateInstance(typeof(InspectSettingsWindow));

            window.position = rect;
            window._Init(ret);
            window.ShowPopup();
        }
Ejemplo n.º 7
0
 public void _Init(ImportSettingsReference reference)
 {
     editor = Editor.CreateEditor(reference);
 }