I've never had this problem before. I keep getting this error:
error CS0266: Cannot implicitly convert type 'float?' to 'float'. An explicit conversion exists (are you missing a cast?)
Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
using LootLocker.Requests;
using TMPro;
public class XPManager : MonoBehaviour
{
public static XPManager instance;
string Collect50XP = "Collect50XP";
public GameObject CollectXpButton;
public Slider LevelSlider;
public TMP_Text CurrentLevelTxt, NextLevelTxt, CurrentXpTxt, XpIncreaseAmount;
private void Awake()
{
DontDestroyOnLoad(gameObject);
if(instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
}
public void Collect50XpEvent()
{
LootLockerSDKManager.TriggeringAnEvent(Collect50XP, (response) =>
{
if (response.success)
{
Debug.Log("Success");
CheckLevel();
}
else
{
Debug.Log("Failed" + response.Error);
}
});
}
public void CheckLevel()
{
LootLockerSDKManager.GetPlayerInfo((response) =>
{
CurrentLevelTxt.text = response.level.ToString();
NextLevelTxt.text = (response.level + 1).ToString();
CurrentXpTxt.text = response.xp.ToString() + " / " + response.level_thresholds.next.ToString();
if (LevelSlider.value == LevelSlider.maxValue)
{
LevelSlider.maxValue = response.level_thresholds.next - (float)response.xp - int.Parse(XpIncreaseAmount.text);
LevelSlider.value = 0;
}
else
{
LevelSlider.value = (float)response.xp - response.level_thresholds.current;
}
});
}
}
It's coming from this line:
LevelSlider.maxValue = response.level_thresholds.next - (float)response.xp - int.Parse(XpIncreaseAmount.text);