/// <summary> /// Converts a <see cref="ColorVec4"/> to a <see cref="Color"/> /// </summary> /// <param name="vec4"></param> /// <returns></returns> public static Color Vector4ToColor(this ColorVec4 vec4) { if (vec4 == null) { return(Color.white); } return(new Color(vec4.R, vec4.G, vec4.B, vec4.A)); }
private void LoadColorPicker(ColorVec4 color) { GameObject itemDisplay = Instantiate(AlterraShippingBuildable.ColorItemPrefab); itemDisplay.transform.SetParent(_colorPageContainer.transform, false); itemDisplay.GetComponentInChildren <Image>().color = color.Vector4ToColor(); var itemButton = itemDisplay.AddComponent <ColorItemButton>(); itemButton.OnButtonClick = OnButtonClick; itemButton.BtnName = "ColorItem"; itemButton.Color = color.Vector4ToColor(); }
private void LoadColorPicker(ColorVec4 color) { GameObject itemDisplay = Instantiate(_colorItemPrefab); itemDisplay.transform.SetParent(_colorPageContainer.transform, false); itemDisplay.GetComponentInChildren <Image>().color = color.Vector4ToColor(); var itemButton = itemDisplay.AddComponent <ColorItemButton>(); itemButton.OnButtonClick = _onButtonClick; itemButton.BtnName = "ColorItem"; itemButton.Color = color.Vector4ToColor(); if (_onInterfaceButton != null) { itemButton.OnInterfaceButton = _onInterfaceButton; } _colorItemsTracker.Add(itemButton); }