Ejemplo n.º 1
0
 public void SetDescriptiveName(string newName)
 {
     if (rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out BaseDisposable nameComponent))
     {
         ((DCLName)nameComponent).ForceSetNewName(newName);
     }
     else
     {
         DCLName name = (DCLName)rootEntity.scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));
         name.ForceSetNewName(newName);
         rootEntity.scene.SharedComponentAttach(rootEntity.entityId, name.id);
     }
     onStatusUpdate?.Invoke(this);
 }
Ejemplo n.º 2
0
    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);
    }