コード例 #1
0
    public void DeleteEntity(DCLBuilderInWorldEntity entityToDelete, bool checkSelection = true)
    {
        if (entityToDelete.IsSelected && checkSelection)
        {
            DeselectEntity(entityToDelete);
        }

        if (selectedEntities.Contains(entityToDelete))
        {
            selectedEntities.Remove(entityToDelete);
            hudController?.UpdateEntitiesSelection(selectedEntities.Count);
        }

        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;

        currentActiveMode?.OnDeleteEntity(entityToDelete);
        biwCreatorController.RemoveLoadingObjectInmediate(entityToDelete.rootEntity.entityId);
        Destroy(entityToDelete);
        if (sceneToEdit.entities.ContainsKey(idToRemove))
        {
            sceneToEdit.RemoveEntity(idToRemove, true);
        }
        hudController?.RefreshCatalogAssetPack();
        EntityListChanged();
        builderInWorldBridge?.RemoveEntityOnKernel(idToRemove, sceneToEdit);
    }