static public DownListener Get(GameObject go) { DownListener listener = go.GetComponent <DownListener>(); if (listener == null) { listener = go.AddComponent <DownListener>(); } return(listener); }
// Use this for initialization void Awake() { if (instance == null) { instance = this; } shootBtn = GameObject.Find("ShootButton").GetComponent <Button>(); DownListener.Get(shootBtn.gameObject).onDown = ShootTheNeedle; InitNeedleForCircle(level); failGame += FailedGame; winGame += WinedGame; PlayerPrefs.DeleteKey("level"); level = PlayerPrefs.GetInt("level", 1); needShoot = 6 + level / 2; ScoreText.text = level.ToString(); NeedShootNum.text = needShoot.ToString(); }