using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class check : MonoBehaviour {
// Use this for initialization
void Start () {
}
int get_bullet_count;
int get_destroy_count;
// Update is called once per frame
void Update () {
if (gameObject.transform.position.y < 0)
{
get_destroy_count = GameObject.Find("MainCamera").GetComponent<attack>().destroy_count++;
get_bullet_count = GameObject.Find("MainCamera").GetComponent<attack>().bullet_count;
GameObject.Find("Text").GetComponent<GUIText>().text = "射弹数:" + get_bullet_count + "消灭数" + get_destroy_count;
}
if(get_destroy_count > 20)
{
GameObject.Find("Text").GetComponent<GUIText>().text = "恭喜你过关了!";
GameObject.Find("MainCamera").GetComponent<attack>().enabled = false;
}
Destroy(gameObject);
}
}
这段代码拉到物体上 没反应 要么物体立刻消失 要么就是没反应 不加整个程序还是正常的