Scoreオブジェクトにアタッチされたスクリプトを取得して、変数を処理
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
public int score;
// Use this for initialization
void Start () {
score = 30;
}
// Update is called once per frame
void Update () {
guiText.text = score.ToString ();
}
}
using UnityEngine;
using System.Collections;
public class Spawner : MonoBehaviour {
public Transform prefab;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
GameObject score = GameObject.Find("Score");
Score scoreScript = score.GetComponent();
scoreScript.score -= 1;
}
}
0 コメント:
コメントを投稿