void Start() { MainText.text = Name; if (TranslationName != "") { MainText.text = TranslationSystem.GetString(TranslationName); } }
// Update is called once per frame public async Task Reload(ModObject v) { await ModSystemTools.LoadPartsAsync(); target = v; Titlebar.text = $"Modify {TranslationSystem.GetString("CAR_"+target.Name)}"; PrepareCatButtons(); PrepareTypeButtons(); StatView.ShowValues(target); }
public async Task SpawnVehicle(int index) { if (preview != null) { Destroy(preview); } VCount.text = $"{index+1}/{Vehicles.Count}"; VehicleInfo info = VTypes.FirstOrDefault(x => x.name == Vehicles[index].Type + "I"); Handling.fillAmount = info.Handling / 100f; Health.fillAmount = info.HP / 180f; Power.fillAmount = info.Power / 400f; Name.text = TranslationSystem.GetString("CAR_" + info.name.Substring(0, info.name.Length - 1)); var v = Vehicles[index]; GameObject gm = new GameObject(); gm.transform.position = new Vector3(0, 1, 0); preview = gm; var modobj = gm.AddComponent <ModObject>(); await modobj.Create(v.Type); foreach (var item in v.InstalledParts) { modobj.AttachPart(item); } InitializedObject = modobj; //await Task.Delay(100); Power2.fillAmount = modobj.GetComponentInChildren <EngineManager>().GetPower() / 400f; Handling2.fillAmount = modobj.GetComponentInChildren <HandlingManager>().GetHandling() / 100f; Health2.fillAmount = modobj.GetComponentInChildren <HealthManager>().GetHealth() / 180f; foreach (var item in CallList) { try { item.Changed(index); } catch { } } }