In this project, I utilized the default Unity User Interface (UGUI) to demonstrate the work within Unity. Below is a brief video clip showcasing it:
As demonstrated in the video, alterations made directly to the sheet have an immediate effect on Unity. This tool can be incredibly useful for creating databases, managing economy, designing UI, and implementing numerous other features.
In this project, I've employed Dependency Injection to manage dependencies. The module I've utilized for this purpose is Extenject. This tool is highly effective for resolving dependencies within the project. If you're unfamiliar with how to use Zenject, I've provided a resource for your reference.
Initially, I established a class to house the data retrieved from the server. Here's what it looks like:
/// <summary>
/// Data class which will be fetched from the server
/// </summary>
[Serializable]
public class EventsData
{
/// <summary>
/// Event Title
/// </summary>
[JsonProperty("Event Title")]
public string EventTitle;
/// <summary>
/// Icon url where icon will be downloaded
/// </summary>
[JsonProperty("Icon")]
public string IconUrl;
/// <summary>
/// Type of reward
/// </summary>
[JsonProperty("Reward Type")]
public RewardType RewardType;
/// <summary>
/// Amount given in the reward
/// </summary>
[JsonProperty("Reward Amount")]
public int RewardAmount;
/// <summary>
/// Description of the event
/// </summary>
public string Description;
/// <summary>
/// Hexcode of the title color
/// </summary>
[JsonProperty("Title Color"), HideInInspector]
public string TitleColorHex;
/// <summary>
/// Hexcode of the body color
/// </summary>
[JsonProperty("Body Color"), HideInInspector]
public string BodyColorHex;
/// <summary>
/// Time of the event
/// </summary>
[JsonProperty("Event Time")]
public TimeSpan EventTime;
/// <summary>
/// Event Type
/// </summary>
[JsonProperty("Event Type")]
public EventType EventType;
/// <summary>
/// Color type of the title
/// </summary>
public Color TitleColor;
/// <summary>
/// Color type of the body
/// </summary>
public Color BodyColor;
/// <summary>
/// Calls when initialize
/// </summary>
public void Init()
{
TitleColor = ParseColor(TitleColorHex);
BodyColor = ParseColor(BodyColorHex);
}
/// <summary>
/// Parse Hexcode to the color type
/// </summary>
/// <param name="HexCode">Hexcode to convert</param>
/// <returns>Color Type of the given hexcode</returns>
Color ParseColor(string HexCode)
{
Color myColor = new Color();
ColorUtility.TryParseHtmlString(HexCode, out myColor);
return myColor;
}
}
public enum EventType
{
Active,
ComingSoon,
Expired
}
This refers to the data storage class that I utilized for caching data.