Пример #1
0
    private void processTextures()
    {
        if (isAvailable)
        {
            string dirName  = Path.GetDirectoryName(assetPath);
            var    textures = GAFAssetUtils.findAssetsAtPath <Texture2D>(dirName, "*.png");
            foreach (var texture in textures)
            {
                if (!string.IsNullOrEmpty(m_TexturesNames.Find(name => name == texture.name)))
                {
                    string          texturePath     = AssetDatabase.GetAssetPath(texture);
                    TextureImporter textureImporter = AssetImporter.GetAtPath(texturePath) as TextureImporter;
                    if (hasCorrectImportSettings(textureImporter))
                    {
                        addTexture(texture);
                    }
                    else if (!GAFPostprocessorHelper.instance.busyTextures.Contains(textureImporter.assetPath))
                    {
                        reimportTexture(textureImporter);
                    }
                }
            }

            if (missingTextures.Count == 0)
            {
                createSharedData();
            }

            AssetDatabase.SaveAssets();
        }
    }
Пример #2
0
        public static void findResourceTextures(GAFTexturesResource _Resource, bool _Reimport)
        {
            var resourcePath = AssetDatabase.GetAssetPath(_Resource);

            if (!string.IsNullOrEmpty(resourcePath))
            {
                var textures = GAFAssetUtils.findAssetsAtPath <Texture2D>(_Resource.currentDataPath, "*.png");
                foreach (var texture in textures)
                {
                    var data = _Resource.missingData.Find(_data => _data.name == texture.name);
                    if (data != null)
                    {
                        if (_Reimport)
                        {
                            var texturePath     = AssetDatabase.GetAssetPath(texture);
                            var textureImporter = AssetImporter.GetAtPath(texturePath) as TextureImporter;
                            if (hasCorrectImportSettings(textureImporter, _Resource))
                            {
                                data.set(texture, getSharedMaterial(texture));
                                m_ImportList.Remove(texturePath);
                                EditorUtility.SetDirty(_Resource);
                            }
                            else
                            {
                                changeTextureImportSettings(textureImporter, _Resource);
                                AssetDatabase.ImportAsset(textureImporter.assetPath, ImportAssetOptions.ForceUpdate);
                            }
                        }
                        else
                        {
                            data.set(texture, getSharedMaterial(texture));
                            EditorUtility.SetDirty(_Resource);
                        }
                    }
                }
            }
        }