Recap: Achievement Popup
Part of the Game Architecture in Unity section of Coddy's Unity journey. Lesson 16 of 64.
Challenge
EasyGive the coin game achievements. AchievementPopup.Show is ready, and the scene wires onUnlocked to it.
Collector: on touching aCoin-tagged object, destroy it and raisepublic event Action<int> OnCoinsChangedwith the total.Achievements: subscribe tocollectorinOnEnable, unsubscribe inOnDisable.- At 1, 3 and 6 coins, invoke
public UnityEvent<string> onUnlockedwithFirst Coin,Pocket Money,Coin Hoarder.
Press Play and collect the coins. Then Check.
Try it yourself
using UnityEngine;
using UnityEngine.Events;
public class Achievements : MonoBehaviour
{
public Collector collector;
}
All lessons in Game Architecture in Unity
1Components, Not Hierarchies
Small ComponentsA Base Enemy ScriptAbstract ComponentsComponents Working TogetherRecap: Modular TurretRecap: Twin Cannon4Serialized Data
Serializable ClassesLists in the InspectorEnums in the InspectorRecap: Loot TableRecap: Roll the Loot2Interfaces in Unity
IDamageableInterfaces and TryGetComponentGetComponentsRecap: Interact KeyRecap: Nearest in Reach3Events
C# Events in UnitySubscribe in OnEnableUnityEvent FieldsEvents Drive the UIRecap: Achievement PopupRecap: Popup TimerPractice on your own: Unity playground