コード例 #1
0
 private void StyleChange()
 {
     UnityEngine.Object.DestroyImmediate(m_ProcessedTexture);
     if (kMLStyle[m_CurrentStyleSelection].processFunc == null)
     {
         m_ProcessedTexture = m_TextureDataProvider.GetReadableTexture2D();
     }
     else
     {
         var assetPath = AssetDatabase.GetAssetPath(m_AssetImporter);
         m_ProcessedTexture = SpriteStyler.Stylize(assetPath, kMLStyle[m_CurrentStyleSelection].name);
     }
     spriteEditor.SetDataModified();
 }
コード例 #2
0
        void OnPostprocessTexture(Texture2D texture)
        {
            var ai = AssetImporter.GetAtPath(assetPath);

            if (ai != null)
            {
                var style = 0;
                if (int.TryParse(ai.userData, out style))
                {
                    if (StyleModule.kMLStyle[style].processFunc != null)
                    {
                        // Only works when texture is set to readable in importer
                        var srcTex = SpriteStyler.Stylize(assetPath, StyleModule.kMLStyle[style].name);
                        var pixels = srcTex.GetPixels32();
                        texture.SetPixels32(pixels);
                        texture.Apply();
                    }
                }
            }
        }