コード例 #1
0
    // Launches a menu of selectable options, populated by initialized dictionary
    static public async Task <object> LaunchMenuAsync(MenuType mType, CancellationToken ct = default)
    {
        GameObject  picker  = GameObject.Instantiate(prefabMenu);
        MenuMonitor monitor = picker.GetComponent <MenuMonitor>();

        object result = await monitor.SetMonitorAsync(mType, ct);

        if (result == null)
        {
            return(null);                // Close returns null
        }
        return(mType switch
        {
            MenuType.Main => (MenuName)result,
            MenuType.Trait => Trait.CreateNew((TraitType)result),
            _ => null,
        });