Exemplo n.º 1
0
    public void DeleteEntity(DCLBuilderInWorldEntity entityToDelete, bool checkSelection = true)
    {
        if (entityToDelete.IsSelected && checkSelection)
        {
            DeselectEntity(entityToDelete);
        }

        if (selectedEntities.Contains(entityToDelete))
        {
            selectedEntities.Remove(entityToDelete);
        }

        string entityName = entityToDelete.GetDescriptiveName();

        if (entityNameList.Contains(entityName))
        {
            entityNameList.Remove(entityName);
        }

        RemoveConvertedEntity(entityToDelete.rootEntity);
        entityToDelete.rootEntity.OnRemoved -= RemoveConvertedEntity;
        entityToDelete.Delete();
        string idToRemove = entityToDelete.rootEntity.entityId;

        Destroy(entityToDelete);
        if (sceneToEdit.entities.ContainsKey(idToRemove))
        {
            sceneToEdit.RemoveEntity(idToRemove, true);
        }
        hudController?.RefreshCatalogAssetPack();
        EntityListChanged();
        builderInWorldBridge?.RemoveEntityOnKernel(idToRemove, sceneToEdit);
    }