- Home /
Error when Subtracting 2 floats. [ISSUE]
Event: So when I have $10 in the game, I should be able to buy a "Flyer" item.
Problem: Unity shows this error when I try do replicate the event:
ArgumentException: method arguments are incompatible System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method, System.Boolean throwOnBindFailure, System.Boolean allowClosed) (at :0) System.Delegate.CreateDelegate (System.Type type, System.Object firstArgument, System.Reflection.MethodInfo method) (at :0) UnityEngine.Events.InvokableCall`1[T1]..ctor (System.Object target, System.Reflection.MethodInfo theFunction) (at :0)
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MoneyClick : MonoBehaviour
{
public float cash;
public GameObject adbutton;
public Text cashAmountText;
public void ClickForMoney()
{
cash += 1f;
print(cash);
}
public void Update()
{
cashAmountText.text = "$" + cash;
}
public void BuyItem(float price)
{
if(cash == 10)
{
cash -= price;
StartCoroutine(Flyers());
print("Flyers Bought");
}
if (cash == 25)
{
cash -= price;
StartCoroutine(Posters());
}
}
IEnumerator Flyers()
{
yield return new WaitForSeconds(1);
cash += 0.1f;
}
IEnumerator Posters()
{
yield return new WaitForSeconds(1);
cash += 0.5f;
}
}
Your answer

Follow this Question
Related Questions
Car keeps pulling itself out of the map. Beginner needs help 0 Answers
Setting TerrainData heights to a float array? 0 Answers
Accuracy issues with Float (Vector3) 2 Answers
How Precise is Random.Range? 1 Answer
if(12f > 12f) = true? 2 Answers