SimpleSpritePackerEditor.SPTools.DoAssetReimport C# (CSharp) Method

DoAssetReimport() public static method

Does asset reimport.
public static DoAssetReimport ( string path, ImportAssetOptions options ) : void
path string Path.
options ImportAssetOptions Options.
return void
        public static void DoAssetReimport(string path, ImportAssetOptions options)
        {
            try
            {
                AssetDatabase.StartAssetEditing();
                AssetDatabase.ImportAsset(path, options);
            }
            finally
            {
                AssetDatabase.StopAssetEditing();
            }
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Sets the asset Read/Write enabled state.
        /// </summary>
        /// <returns><c>true</c>, if set read write enabled was asseted, <c>false</c> otherwise.</returns>
        /// <param name="path">Path.</param>
        /// <param name="enabled">If set to <c>true</c> enabled.</param>
        /// <param name="force">If set to <c>true</c> force.</param>
        public static bool AssetSetReadWriteEnabled(string path, bool enabled, bool force)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            TextureImporter ti = AssetImporter.GetAtPath(path) as TextureImporter;

            if (ti == null)
            {
                return(false);
            }

            TextureImporterSettings settings = new TextureImporterSettings();

            ti.ReadTextureSettings(settings);

            if (force || settings.readable != enabled)
            {
                settings.readable = enabled;
                ti.SetTextureSettings(settings);
                SPTools.DoAssetReimport(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
            }

            return(true);
        }
All Usage Examples Of SimpleSpritePackerEditor.SPTools::DoAssetReimport