Quantcast
Channel: Answers for "Accessing variables from GameObjects in an array"
Viewing all articles
Browse latest Browse all 6

Answer by Tetrad

$
0
0

If Unity itself is crashing (i.e. not the game not working), make sure your property isn't causing an infinite loop.

This will cause unity to break:

string enemyName
{
    get { return enemyName; } // infinite loop;
}

In general, properties and class names are upper case to prevent issues like this:

public class EnemyHUD : MonoBehaviour
{
    string enemyName; // private member variable
    public string EnemyName // public property
    {
        get { return enemyName; }
    }
}

See also this question


Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>