public bool LoadMaterial(UI2DSprite uiSprite, string fileName) { if (uiSprite == null || string.IsNullOrEmpty(fileName)) { return(false); } Material mat; int result = SetMaterialResource(uiSprite, fileName, out mat); if (result == 0) { uiSprite.material = null; return(false); } if (result == 2) { uiSprite.material = GameObject.Instantiate(mat); AddOrSetInstanceMaterialMap(uiSprite.GetInstanceID(), uiSprite.material); } else if (result == 1) { if (uiSprite.material == null) { mat = GetInstanceMaterialMap(uiSprite.GetInstanceID()); uiSprite.material = mat; } } return(mat != null); }
private void ClearInstanceMaterialMap(UI2DSprite target) { if (target == null) { return; } ClearInstanceMaterialMap(target.GetInstanceID()); }