Repository: UnityTechnologies/open-project-1
File: UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/FadeChannelSO.cs (C#)

Code before:
[CreateAssetMenu(menuName = "Events/UI/Fade Channel")]
public class FadeChannelSO : ScriptableObject
{
	public UnityAction<bool, float, Color> OnEventRaised;
	/// <summary>
	/// Generic fade function. Communicates with <seealso cref="FadeManager.cs"/>.
	/// </summary>
	/// <param name="fadeIn">If true, the rectangle fades in. If false, the rectangle fades out.</param>
	/// <param name="duration">How long it takes to the image to fade in/out.</param>
	/// <param name="color">Target color for the image to reach. Disregarded when fading out.</param>
	public void Fade(bool fadeIn, float duration, Color color)
	{
		if (OnEventRaised != null)
			OnEventRaised.Invoke(fadeIn, duration, color);
	}

	/// <summary>
	/// Generic fade function. Communicates with <seealso cref="FadeManager.cs"/>.
	/// </summary>
	/// <param name="fadeIn">If true, the rectangle fades in. If false, the rectangle fades out.</param>
	/// <param name="duration">How long it takes to the image to fade in/out.</param>
	public void Fade(bool fadeIn, float duration)
	{
		if (OnEventRaised != null)
			OnEventRaised.Invoke(fadeIn, duration, new Color(0, 0, 0, 1));
	}

	/// <summary>
	/// Fade helper function to simplify usage. Fades in the rectangle.
	/// </summary>
	/// <param name="duration">How long it takes to the image to fade in.</param>
	/// <param name="color">Target color for the image to reach.</param>
	public void FadeIn(float duration, Color color)
	{
		Fade(true, duration, color);
	}
	/// <summary>
	/// Fade helper function to simplify usage. Fades in the rectangle.
	/// </summary>
	/// <param name="duration">How long it takes to the image to fade in.</param>
	public void FadeIn(float duration)
	{
		Fade(true, duration, new Color(0, 0, 0, 1));
	}
	/// <summary>
	/// Fade helper function to simplify usage. Fades out the rectangle.
	/// </summary>
	/// <param name="duration">How long it takes to the image to fade out.</param>
	public void FadeOut(float duration)
	{
		Fade(false, duration, new Color(0, 0, 0, 1));

Review comment (suggestion):
You can give parameters a default value so that you don't have to write the same method multiple times.
Here an example:
```suggestion
	public void Fade(bool fadeIn, float duration, Color color = default)
	{
		if (color == default) color = Color.black;
		if (OnEventRaised != null)
			OnEventRaised.Invoke(fadeIn, duration, color);
	}
```
This would work for the FadeIn-Methods as well

FYI: default(Color) == new Color(0, 0, 0, 0) and that's the only problem: If you want to fade in to or out from transparent but I don't see how that makes any sense so I would ignore that

EDIT: I'm pretty sure just writing `default` instead of `default(Color)` should be enough so I changed it

Code after:
[CreateAssetMenu(menuName = "Events/UI/Fade Channel")]
public class FadeChannelSO : ScriptableObject
{
	public UnityAction<bool, float, Color> OnEventRaised;
	/// <summary>
	/// Generic fade function. Communicates with <seealso cref="FadeManager.cs"/>.
	/// </summary>
	/// <param name="fadeIn">If true, the rectangle fades in. If false, the rectangle fades out.</param>
	/// <param name="duration">How long it takes to the image to fade in/out.</param>
	/// <param name="color">Target color for the image to reach. Disregarded when fading out.</param>
	public void Fade(bool fadeIn, float duration, Color color = default)
	{
		if (color == default && fadeIn) // If no fadein color is assigned, black is given as default. If we are supposed to fadeout the rectangle, default is simply passed through.
			color = Color.black;
		if (OnEventRaised != null)
			OnEventRaised.Invoke(fadeIn, duration, color);
	}

	/// <summary>
	/// Fade helper function to simplify usage. Fades in the rectangle.
	/// </summary>
	/// <param name="duration">How long it takes to the image to fade in.</param>
	/// <param name="color">Target color for the image to reach.</param>
	public void FadeIn(float duration, Color color = default)
	{
		if (color == default)
			color = Color.black;
		Fade(true, duration, color);
	}
	/// <summary>
	/// Fade helper function to simplify usage. Fades out the rectangle.
	/// </summary>
	/// <param name="duration">How long it takes to the image to fade out.</param>
	public void FadeOut(float duration, Color color = default)
	{
		Fade(false, duration, color);
	}
}