Svp j'ai un problème j aimerai bien avoir accès aux objets que j 'ai crée dans un script et les detruires dans un autre script.
pour créer
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
public class spawn : MonoBehaviour {
public GameObject objekt;
public GameObject cube;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("a"))
{
cube = Instantiate (objekt);
objekt.tag = "spawn";
}
}
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
public class delete : MonoBehaviour {
public spawn obj;
GameObject [] oj;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//objeKt = GameObject.FindGameObjectsWithTag ("spawn");
if (Input.GetKeyDown ("s")) {
obj = GameObject.FindGameObjectsWithTag ("spawn").GetComponent (spawn);
Destroy (obj.cube);
}
}
}
Les balises code SVP
Merci de lire la Netiquette.