Question by
Forbidden_Duck · Jan 16, 2017 at 01:31 AM ·
uibeginnerscorescore system
Scoring Points with UI Problem!
Hi, I am trying to make the text on the left go to Score: 1 when the ball hits the left wall (Shown in picture)
These are the scripts
WallLeft:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ScorePoints1 : MonoBehaviour {
//public LvlManager lvlman;
public int ballPoints = 1;
public GameObject manager;
ScoreLeft lvlman;
// Use this for initialization
void Awake()
{
lvlman = manager.GetComponent<ScoreLeft>();
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Ball")
{
lvlman.AddPoints(ballPoints);
Destroy(this.gameObject);
}
}
}
This is ScoreLeft:
using UnityEngine; using UnityEngine.UI;
public class ScoreLeft : MonoBehaviour {
public int score;
public bool ended;
public Text scoretxt;
public GameObject WallLeft;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void AddPoints(int points)
{
score += points;
}
}
screenshot-19.png
(150.1 kB)
Comment