private GameObject NewUIObject(string name, GameObject prefab, Transform parent, Sprite sprite, Color color) { GameObject GO; if (prefab != null) { GO = SafeOperations.Instantiate(prefab, parent); } else { GO = SafeOperations.NewGameObject(name, parent, typeof(RectTransform), typeof(CanvasRenderer)); Image img = GO.SafeAddComponent <Image> (); img.sprite = sprite; img.color = color; GO.layer = 5; } return(GO); }