Problemas para destruir clone de prefab
4 participantes
Página 1 de 1
Problemas para destruir clone de prefab
Bom criei este script:
If you really want to remove an asset use DestroyImmediate (theObject, true);
UnityEngine.Object:Destroy(Object)
Create:Update() (at Assets/Scrips/TEST/Create.cs:38)
se alguém puder sugerir algo para resolver este erro ficarei mt agradecido
- Código:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Create : MonoBehaviour {
[Header("OUTROS")]
public GameObject Localparainstaciar;
public Vector3 Posicao, rotacao;
[Header("Objetos")]
public GameObject Pilastra;
public GameObject Cubo;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update (){
if (Input.GetKeyDown ("e")) {
RaycastHit hit;
Physics.Raycast (transform.position, transform.forward, out hit, 1000);
Instantiate (Cubo, hit.point - transform.forward* 0.5f, Quaternion.Euler(hit.normal));
Debug.DrawLine (transform.position, hit.point);
}
if (Input.GetKeyDown ("q")) {
RaycastHit hit;
Physics.Raycast (transform.position, transform.forward, out hit, 1000);
Instantiate (Pilastra, hit.point - transform.forward* 0.5f, Quaternion.Euler(hit.normal));
Debug.DrawLine (transform.position, hit.point);
}
if (Input.GetMouseButtonDown (0)) {
RaycastHit hit;
Physics.Raycast (transform.position, transform.forward, out hit, 1000);
Destroy (Cubo);
}
}
}
If you really want to remove an asset use DestroyImmediate (theObject, true);
UnityEngine.Object:Destroy(Object)
Create:Update() (at Assets/Scrips/TEST/Create.cs:38)
se alguém puder sugerir algo para resolver este erro ficarei mt agradecido
BRGC- ProgramadorMaster
- PONTOS : 2814
REPUTAÇÃO : 59
Idade : 19
Áreas de atuação : C#, C++, C, Flutter
Respeito as regras :
Re: Problemas para destruir clone de prefab
Boa tarde,
De uma olhada aqui.
https://docs.unity3d.com/ScriptReference/Object.Destroy.html
De uma olhada aqui.
https://docs.unity3d.com/ScriptReference/Object.Destroy.html
Alessandra Matheus- Membro
- PONTOS : 2938
REPUTAÇÃO : 2
Respeito as regras :
Re: Problemas para destruir clone de prefab
Você não pode destroir um prefab, você apenas pode destroir o prefab instanciado, no caso faz um GameObject receber o objeto instanciado ai sim você poderá o destroir!
Exemplo:
Exemplo:
- Código:
GameObject objetoInstanciado = Instantiate (Pilastra, hit.point - transform.forward* 0.5f, Quaternion.Euler(hit.normal))as GameObject;
Destroy(objetoInstanciado,3);
rafaelllsd- ProgramadorMaster
- PONTOS : 5004
REPUTAÇÃO : 507
Idade : 23
Áreas de atuação : Unity, Audacity, Blender, Gimp, C#, JS, MySQL.
Respeito as regras :
SkylineZ5- Iniciante
- PONTOS : 1633
REPUTAÇÃO : 0
Respeito as regras :
Re: Problemas para destruir clone de prefab
Eu resolvi o meu colocando na VOID UPDATE, Assim:
void Update()
{
Destroy(gameObject, 1f);
}
void Update()
{
Destroy(gameObject, 1f);
}
SkylineZ5- Iniciante
- PONTOS : 1633
REPUTAÇÃO : 0
Respeito as regras :
Tópicos semelhantes
» Problema ao destruir Clone de um Prefab
» PREFAB(clone)
» Como destruir objecto clone?
» Duvida com Nome do Objeto Prefab (Clone)
» [DUVIDA] Como destruir um GameObject (cubo etc...) sem destruir seus "afilhados"
» PREFAB(clone)
» Como destruir objecto clone?
» Duvida com Nome do Objeto Prefab (Clone)
» [DUVIDA] Como destruir um GameObject (cubo etc...) sem destruir seus "afilhados"
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos