unity のゲームオブジェクト→UI→textで作成したscoreにボールがタグplayerに衝突したら100点他なら150点スコアに追加するというスクリプトを作成したがボールに
そのスクリプトをいれたがInspector内のスクリプトにUIをいれることが出来ないのでですがどこをいじれば良いのでしょうか
下記にプログラムを写します
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Gamescore : MonoBehaviour {
public Text scoreText; //Text用変数
private int score = 0; //スコア計算用変数
// Use this for initialization void Start () { score = 0; SetScore(); //初期スコアを代入して表示 } void OnCollisionEnter( Collision collision ) { string yourTag = collision.gameObject.tag; if( yourTag == "Player" ) { score += 150; } else { score += 100; } SetScore(); } void SetScore() { scoreText.text = string.Format( "Score:{0}", score ); } // Update is called once per frame void Update () { }
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。