public static void SetImageSprite(Image image, GameObject prefab, bool isShowSpecMatrial = false) { if (image == null) { return; } if (prefab == null) { image.sprite = null; return; } SpriteRenderer component = prefab.GetComponent <SpriteRenderer>(); if (component != null) { image.sprite = component.sprite; isShowSpecMatrial = false; if (isShowSpecMatrial && component.sharedMaterial != null && component.sharedMaterial.shader != null && !component.sharedMaterial.shader.name.Equals(CUIUtility.s_ui_defaultShaderName)) { float[] materailMaskPars = CUIUtility.GetMaterailMaskPars(image.material); image.material = component.sharedMaterial; image.material.shaderKeywords = component.sharedMaterial.shaderKeywords; CUIUtility.SetMaterailMaskPars(materailMaskPars, image.material); } else if (isShowSpecMatrial) { image.material = null; } } if (image is Image2) { SGameSpriteSettings component2 = prefab.GetComponent <SGameSpriteSettings>(); Image2 image2 = image as Image2; image2.alphaTexLayout = ((!(component2 != null)) ? ImageAlphaTexLayout.None : component2.layout); } }