void Init()
{
if (needMaterialInstance)
{
if (spriteCollection)
{
tk2dSpriteCollectionData spriteCollectionInst = spriteCollection.inst;
for (int i = 0; i < spriteCollectionInst.materials.Length; ++i)
{
if (spriteCollectionInst.materials[i] == material)
{
materialInst = spriteCollectionInst.materialInsts[i];
break;
}
}
if (materialInst == null)
Debug.LogError("Fatal error - font from sprite collection is has an invalid material");
}
else
{
materialInst = Instantiate(material) as Material;
materialInst.hideFlags = HideFlags.DontSave;
}
}
else
{
materialInst = material;
}
}