I am having serious problems in one of my scripts, which is trying to use a function from another script within a function in the first script, in getting the script to do it. Here is the basics:
public class GameTurn : MonoBehaviour
(This is the script I am trying to do the accessing with.)
public class CardManager : MonoBehaviour
(This is the script that the function I am trying to use is located.)
void CardPoints ()
(This is the function that I am trying to use in the first script.)
You need a reference to an object of your CardManager, then you can simply call the method on it.
public class GameTurn : MonoBehaviour
{
public CardManager cardManager; // Assign this in the inspector.
public void SomeMethod()
{
if (!cardManager)
{
Debug.LogError("You have not assigned anything to cardManager in the inspector!");
}
else
{
cardManager.CardPoints(); // Call the method on the object.
}
}
}