when I first imported the resource(just copy into project assets folder and switch back to the Unity),it generates two materials: A.mat and B.mat
it looks ok
but when I manually do reimport on the resource folder,it will generate some extra-blendmodes materials:
A-Additive.mat
A-Screen.mat
B-Additive.mat
B-Multply.mat
B-Screen.mat
why can the same resource be imported twice and get two different results?
and here is the my asset postProcessor ,for automatically enable the straight alpha input and transparence
using UnityEngine;
using System.Collections;
using UnityEditor;
public class MyEditor : AssetPostprocessor {
public void OnPreprocessModel()
{
}
public void OnPostprocessModel(GameObject go)
{
}
public void OnPreprocessTexture()
{
}
public void OnPostprocessTexture(Texture2D tex)
{
}
public void OnPostprocessAudio(AudioClip clip)
{
}
public void OnPreprocessAudio()
{
}
public static void OnPostprocessAllAssets(string[]importedAsset,string[] deletedAssets,string[] movedAssets,string[]movedFromAssetPaths)
{
int id = 0;
string[] materialGUIDS = UnityEditor.AssetDatabase.FindAssets("t:material");
foreach (var guid in materialGUIDS)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
if ( path.IndexOf("Assets/Resources/Spine") < 0 )
continue;
var mat = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(path);
int _StraightAlphaID = Shader.PropertyToID("_StraightAlphaInput");
if (mat.HasProperty(_StraightAlphaID) && mat.GetInt(_StraightAlphaID) == 0)
{
mat.EnableKeyword("_STRAIGHT_ALPHA_INPUT");
mat.SetInt(_StraightAlphaID, (int)1);
EditorUtility.SetDirty(mat);
id ++;
}
}
string[] materialTEXS = UnityEditor.AssetDatabase.FindAssets("t:texture");
foreach (var guid in materialTEXS)
{
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
if ( path.IndexOf("Assets/Resources/Spine") < 0 )
continue;
TextureImporter ti = (TextureImporter)TextureImporter.GetAtPath(path);
if (ti && ti.alphaIsTransparency == false)
{
ti.alphaIsTransparency = true;
ti.SaveAndReimport();
id ++;
}
}
if ( id > 0 )
{
UnityEditor.AssetDatabase.SaveAssets();
UnityEditor.AssetDatabase.Refresh();
}
}
}