- Home /
Question by
Quast · Jul 12, 2016 at 07:59 AM ·
gameobjectslinkvar
Link var with GameObjects
I want to link var with gameobject, Can i do it ? I can do it by using
using UnityEngine; using System.Collections;
public class vc : MonoBehaviour {
public GameObject player;
public zs[] _enemy;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
var objects = GameObject.FindGameObjectsWithTag("enemy");
var objectCount = objects.Length;
// objects = _enemy; here i want to link var with the game object _enemy which it my problem
Debug.Log(objectCount);
foreach (var obj in objects) {
if(GameObject.FindWithTag("enemy").activeSelf == false)
{
// here obj.delete_enemy();
}
}
foreach(var e in _enemy) {
if (e.enemy.activeSelf == false) // this one run well without problem can i do same think with above one ?
{
e.delete_enemy();
Debug.Log("delete");
}
}
}
Comment