GameContolManger.CS
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class GameControlManager : MonoBehaviour
{
public static int totalPoint;
public static int coinPoint;
public static int CHestPoint;
public static int RingPoint;
public static int GoldCHestPoint;
public Text CoinPoint;
public Text ChestUiPoint;
public Text RingUIiPoint;
public Text GoldChestUIPoint;
public GameObject menuSet;
FadeInAndOut fadeIn;
public GameObject UIResult;
public GameObject GameOverWindow;
public GameObject UIKeyGet;
public GameObject Player;
Saver saver;
void Start (){
coinPoint=0;
CHestPoint=0;
GoldCHestPoint=0;
RingPoint=0;
}
private void Update()
{
CoinPoint.text = (totalPoint + coinPoint).ToString();
ChestUiPoint.text = (CHestPoint).ToString();
RingUIiPoint.text = (RingPoint).ToString();
GoldChestUIPoint.text = (GoldCHestPoint).ToString();
}
Saver.cs
public class Saver : MonoBehaviour {
public int score;//score holder
public string LevelManagerName = "LevelManager";
public int curLevel;//loaded from GameManager
public int curWorld;//loaded from GameManager
private int NextWorld;
private int NextLevel;
//at start of the level read the loaded level
void Awake()
{
curLevel = GameManager.Instance.loadedLevel;
curWorld = GameManager.Instance.loadedWorld;
}
public void SetScore(int scoreAmount)//call this function once the level is completed and pass in this score
{
score = scoreAmount;//stores the score
SaveMyGame();
}
GameContolManger.CS 안에 CoinPoint.text 값(또는 int coinpoint값)을
Saver.cs안의 score값으로 보내려면 어떻게 해야 하나요??
public Saver saver ; // 인스펙터에서 바인딩 작당한 곳에서 saver.SetScore(coinpoint);
와와와 베리베리땡유. 메리크리스마스~~
라이브러리 쓸때 웬만한 기능 함수명을 모르겠으면 Get, Set, On 으로 시적하는 함수 찾아보면 보통 있음
디씨에서 코드 하이라이트 어케했음? 깔끔하고 좋네
IDE에서 복사하고 여기 붙여넣으면 됨