DCLBuilderInWorldEntity SetupEntityToEdit(IDCLEntity entity, bool hasBeenCreated = false) { if (!convertedEntities.ContainsKey(GetConvertedUniqueKeyForEntity(entity))) { DCLBuilderInWorldEntity entityToEdit = Utils.GetOrCreateComponent <DCLBuilderInWorldEntity>(entity.gameObject); entityToEdit.Init(entity, editMaterial); convertedEntities.Add(entityToEdit.entityUniqueId, entityToEdit); entity.OnRemoved += RemoveConvertedEntity; entityToEdit.IsNew = hasBeenCreated; string entityName = entityToEdit.GetDescriptiveName(); var catalogItem = entityToEdit.GetCatalogItemAssociated(); if ((string.IsNullOrEmpty(entityName) || entityNameList.Contains(entityName)) && catalogItem != null) { entityName = GetNewNameForEntity(catalogItem); SetEntityName(entityToEdit, entityName); } else if (!string.IsNullOrEmpty(entityName) && !entityNameList.Contains(entityName)) { entityNameList.Add(entityName); } return(entityToEdit); } else { return(convertedEntities[GetConvertedUniqueKeyForEntity(entity)]); } }
public void SetEntityName(DCLBuilderInWorldEntity entityToApply, string newName, bool sendUpdateToKernel = true) { string currentName = entityToApply.GetDescriptiveName(); if (currentName == newName) { return; } if (entityNameList.Contains(newName)) { newName = GetNewNameForEntity(newName); } if (entityNameList.Contains(currentName)) { entityNameList.Remove(currentName); } entityToApply.SetDescriptiveName(newName); entityNameList.Add(newName); if (sendUpdateToKernel) { builderInWorldBridge?.ChangedEntityName(entityToApply, sceneToEdit); } }
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); }
void SetInfo(DCLBuilderInWorldEntity entityToEdit) { if (this != null) { if (string.IsNullOrEmpty(entityToEdit.GetDescriptiveName())) { nameInputField.text = entityToEdit.rootEntity.entityId; nameTxt.text = entityToEdit.rootEntity.entityId; } else { nameInputField.text = entityToEdit.GetDescriptiveName(); nameTxt.text = entityToEdit.GetDescriptiveName(); } //NOTE (Adrian): this is done to force the text component to update, otherwise it won't show the text, seems like a bug on textmeshpro to me nameInputField.textComponent.enabled = true; if (entityToEdit.IsVisible) { showImg.color = iconsSelectedColor; } else { showImg.color = iconsUnselectedColor; } if (entityToEdit.IsLocked) { lockImg.color = iconsSelectedColor; } else { lockImg.color = iconsUnselectedColor; } if (entityToEdit.IsSelected) { selectedImg.color = entitySelectedColor; } else { selectedImg.color = entityUnselectedColor; } } }
public void EntityDuplicateName() { string name = "Test"; entityHandler.SetEntityName(entity, name); DCLBuilderInWorldEntity createdEntity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); entityHandler.SetEntityName(createdEntity, name); Assert.AreNotEqual(createdEntity.GetDescriptiveName(), name); }
public void DescriptiveName() { //Arrange string newName = "testingName"; //Act entity.SetDescriptiveName(newName); //Assert Assert.AreEqual(entity.GetDescriptiveName(), newName); }
public void UpdateEntityName(DCLBuilderInWorldEntity entity) { string currentName = entity.GetDescriptiveName(); titleTxt.text = currentName; if (!isChangingName) { nameIF.SetTextWithoutNotify(currentName); } }
internal void UpdateEntityName(DCLBuilderInWorldEntity entity) { if (entity == null) { return; } string currentName = entity.GetDescriptiveName(); if (!isChangingName) { entityInformationView.SetNameIFText(currentName); } }
public void BuilderInWorldEntityComponents() { string entityId = "1"; TestHelpers.CreateSceneEntity(scene, entityId); DCLBuilderInWorldEntity biwEntity = Utils.GetOrCreateComponent <DCLBuilderInWorldEntity>(scene.entities[entityId].gameObject); biwEntity.Init(scene.entities[entityId], null); Assert.IsTrue(biwEntity.entityUniqueId == scene.sceneData.id + scene.entities[entityId].entityId, "Entity id is not created correctly, this can lead to weird behaviour"); SmartItemComponent.Model model = new SmartItemComponent.Model(); string jsonModel = JsonUtility.ToJson(model); scene.EntityComponentCreateOrUpdateFromUnity(entityId, CLASS_ID_COMPONENT.SMART_ITEM, jsonModel); Assert.IsTrue(biwEntity.HasSmartItemComponent()); DCLName name = (DCLName)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME)); scene.SharedComponentAttach(biwEntity.rootEntity.entityId, name.id); DCLName dclName = biwEntity.rootEntity.TryGetComponent <DCLName>(); Assert.IsNotNull(dclName); string newName = "TestingName"; dclName.ForceSetNewName(newName); Assert.AreEqual(newName, biwEntity.GetDescriptiveName()); DCLLockedOnEdit entityLocked = (DCLLockedOnEdit)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.LOCKED_ON_EDIT)); scene.SharedComponentAttach(biwEntity.rootEntity.entityId, entityLocked.id); DCLLockedOnEdit dclLockedOnEdit = biwEntity.rootEntity.TryGetComponent <DCLLockedOnEdit>(); Assert.IsNotNull(dclLockedOnEdit); bool isLocked = true; dclLockedOnEdit.SetIsLocked(isLocked); Assert.AreEqual(biwEntity.IsLocked, isLocked); }