private void Revert()
 {
     _configData  = SpriteConfigData.GetData(_originalUserData);
     _meshCreator = MeshCreatorBase.GetInstnace(_configData);
     _preview.SetWireframes(_meshCreator.GetMeshWireframes());
     _importData.textureImporter.userData = _originalUserData;
     _isDataChanged = false;
 }
        public SpriteProcessor(Sprite sprite, string assetPath)
        {
            _importData       = new SpriteImportData(sprite, assetPath);
            _originalUserData = _importData.textureImporter.userData;
            _configData       = SpriteConfigData.GetData(_originalUserData);
            _meshCreator      = MeshCreatorBase.GetInstnace(_configData);
            _preview          = new SpritePreview(_meshCreator.GetMeshWireframes());

            Undo.undoRedoPerformed += UndoReimport;
        }
        private void UndoReimport()
        {
            _configData    = SpriteConfigData.GetData(_importData.textureImporter.userData);
            _isDataChanged = true;

            foreach (var t in _targets)
            {
                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(t),
                                          ImportAssetOptions.ForceUpdate |
                                          ImportAssetOptions.DontDownloadFromCacheServer);
            }
        }
Esempio n. 4
0
        private void OnPostprocessSprites(Texture2D texture, Sprite[] sprites)
        {
            TextureImporter         textureImporter         = assetImporter as TextureImporter;
            TextureImporterSettings textureImporterSettings = new TextureImporterSettings();

            textureImporter.ReadTextureSettings(textureImporterSettings);
            SpriteConfigData configData = SpriteConfigData.GetData(textureImporter.userData);

            if (textureImporterSettings.spriteMeshType != SpriteMeshType.Tight || !configData.overriden)
            {
                return;
            }

            MeshCreatorBase creator = MeshCreatorBase.GetInstnace(configData);

            foreach (var sprite in sprites)
            {
                creator.OverrideGeometry(sprite, configData);
            }
        }
        private void UndoReimport()
        {
            _configData    = SpriteConfigData.GetData(_mainImportData.textureImporter.userData);
            _isDataChanged = true;

            if (_targets == null)
            {
                return;
            }

            foreach (var t in _targets)
            {
                string path = AssetDatabase.GetAssetPath(t);

                if (!string.IsNullOrEmpty(path))
                {
                    AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.DontDownloadFromCacheServer);
                }
            }
        }