-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.cs
40 lines (32 loc) · 1.14 KB
/
Character.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using Il2CppAssets.Scripts.PeroTools.Commons;
using Il2CppAssets.Scripts.PeroTools.Managers;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace QuickSwitchCombination;
[RegisterTypeInIl2Cpp]
internal class Character : MonoBehaviour
{
private int _count;
public Character(IntPtr intPtr) : base(intPtr)
{
}
private void Start()
{
_count = transform.parent.gameObject.GetComponent<Count>().count;
var dropdown = GetComponent<Dropdown>();
dropdown.ClearOptions();
List<string> characters = new();
for (var i = 0; i < Singleton<ConfigManager>.instance["character"].Count; i++)
{
characters.Add(Singleton<ConfigManager>.instance.GetJson("character", true)[i]["cosName"].ToObject<string>());
}
dropdown.AddOptions(characters);
dropdown.value = Save.Settings.Data[_count].Character;
dropdown.onValueChanged.AddListener((UnityAction<int>)OnValueChanged);
}
private void OnValueChanged(int index) => Save.Settings.Data[_count].Character = index;
}