Не получаеться
Цитата
Assets/Scripts HARD/EnemyHRD.cs(16,13): error CS0120: An object reference is required to access non-static member `ScoreHRD.scoreH'
Assets/Scripts HARD/EnemyHRD.cs(25,23): error CS0120: An object reference is required to access non-static member `ScoreHRD.scoreH'
Assets/Scripts HARD/EnemyHRD.cs(27,59): error CS0120: An object reference is required to access non-static member `ScoreHRD.scoreH'
Код:
Код
using UnityEngine;
using System.Collections;
public class EnemyHRD: MonoBehaviour
{
private ScoreHRD scoreH; // Reference to the Score script.
private HighScoreHRD highscoreH;
public GameObject NewHighScoreH;
public void OnTriggerEnter (Collider other)
{
if (other.gameObject.tag == "Gem")
{
ScoreHRD.scoreH += 10;
Destroy (other.gameObject);
}
}
public void Update()
{
if (ScoreHRD.scoreH > PlayerPrefs.GetInt ("highscoreHRD"))
{
PlayerPrefs.SetInt ("highscoreHRD", ScoreHRD.scoreH);
NewHighScoreH.SetActive (true);
}
}
}
Ну а еще из ScoreHRD
Код
using UnityEngine;
using System.Collections;
public class ScoreHRD : MonoBehaviour
{
public int scoreH = 0; // The player's score.\
private int previousScoreH = 0; // The score in the previous frame.
void Update ()
{
// Set the score text.
GetComponent<GUIText>().text = "Score: " + scoreH;
// If the score has changed...
if(previousScoreH!= scoreH)
// Set the previous score to this frame's score.
previousScoreH = scoreH;
}
}
Что не так?