예제 #1
0
 public void SetSpriteProcessor(Object t, string assetPath)
 {
     if (SpriteProcessor == null && t is Sprite sprite && !string.IsNullOrEmpty(assetPath) && assetPath.StartsWith("Assets"))
     {
         SpriteProcessor = new SpriteProcessor(sprite, assetPath);
     }
 }
        private void OnPostprocessSprites(Texture2D _, Sprite[] sprites)
        {
            TextureImporter         textureImporter         = assetImporter as TextureImporter;
            TextureImporterSettings textureImporterSettings = new TextureImporterSettings();

            textureImporter.ReadTextureSettings(textureImporterSettings);

            //override mesh
            foreach (var sprite in sprites)
            {
                SpriteProcessor spriteProcessor = new SpriteProcessor(sprite, assetPath);
                spriteProcessor.OverrideGeometry();
            }

            //auto rename
            if (SpriteAssistSettings.Settings.enableRenameMeshPrefabAutomatically)
            {
                EditorApplication.delayCall += () =>
                {
                    Sprite           sprite     = AssetDatabase.LoadAssetAtPath <Sprite>(assetPath);
                    SpriteImportData importData = new SpriteImportData(sprite, assetPath);

                    if (importData.HasMeshPrefab)
                    {
                        PrefabUtil.TryRename(importData.assetPath, importData.MeshPrefab);
                    }
                };
            }
        }
예제 #3
0
        protected override void OnEnable()
        {
            base.OnEnable();

            Sprite sprite    = target as Sprite;
            string assetPath = AssetDatabase.GetAssetPath(target);

            if (sprite == null || string.IsNullOrEmpty(assetPath))
            {
                //reimport
                return;
            }

            _spriteProcessor = new SpriteProcessor(sprite, assetPath);
        }