Hello, I’m currently trying to create some achievements but I don’t really know how to optimize this.
As you can see below I currently have 55 achievements but is pretty annoying to do it through the inspector, I’d like to set name, description, ID, goal, reward amount through code to edit it on the fly.
This is the Achievement class inside my AchievementManager
[System.Serializable]
public class Achievement
{
//Base achievement
public Sprite icon;
public string name;
public string description;
//Achievement Stuff
public string ID;
public double current;
public double goal;
public bool isCompleted;
public bool isClaimed;
public bool isHidden;
//Reward
public Sprite rewardIcon;
public double rewardAmount;
public RewardType rewardType;
}
#endregion
I’m using a “Dictionary” script (Bad name and look I know) to save the achievements name
I was wondering if something like converting the names into a single string array and then using a loop to go through the achievements names to set the name of them like:
for (int i =0; i< stringArray.Lenght; i++) {
achievement.name = stringArray[i];
}
and if I can do the same with description, ID, goal, reward amount. I don’t mind to set 55 or 200 images because is faster than this.
Like I said I have to fill this class below for every achievement I want to add, the icon and reward is not a big deal but descriptions, names, and IDs yes so I wanted to optimize this part and I don’t like the way I’m doing now because if I want to add an achievement under a “category” I have to redo everything (I like to be organized and put every achievement of the same category together then the other category and so on).
[System.Serializable]
public class Achievement
{
//Base achievement
public Sprite icon;
public string name;
public string description;
//Achievement Stuff
public string ID;
public double current;
public double goal;
public bool isCompleted;
public bool isClaimed;
public bool isHidden;
//Reward
public Sprite rewardIcon;
public double rewardAmount;
public RewardType rewardType;
}
I posted a picture of my Dictionary script (bad script name and if you like your like please don’t look at it), I convert the IDs to a string[ ] but I have to give to every achievement a name before populating the canvas (which is done when pressing on a button) but I’m unsure on how to do this
to add progress to achievement. Now I need to optimize the achievement scroll view because it lags when I open it (since it loads ~70 achievements even if not visible), if you have a suggestion please let me know! I prefer a solution made using code and not pre-made by someone