Open tapanij opened 10 years ago
Updated title: noticed that also AssetReference and AssetReferenceList values are not set properly.
Note to self: make jsmodules\Tests\Api\Scene\DynamicComponent.js to test creation, writing and reading of each supported attribute type.
Are you using Rocket or rex core/release? This would be helpful to know.
Not 100% sure if I used linux tundra or rocket. Probably linux
I've worked on this issue now and I think everything should be now resolved and a wider range of script setters not only for EC_DynamicComponent::SetAttribute
but for normal attributes as well (eg. mesh.meshRef
and placeable.parentRef
).
Here is a quick rundown what you can do now (These will also for work with EC_DynamicComponent::SetAttribute
):
mesh.meshRef = "test.mesh";
mesh.meshRef = { ref : "test.mesh", type : "OptionalType" };
mesh.meshRef = new AssetReference("test.mesh", "OptionalType");
mesh.materialRefs = [ "test1.material", "test2.material" ];
mesh.materialRefs = [ "test1.material",
{ ref : "test2.material", type : "OptionalType" },
new AssetReference("test3.material", "OptionalType")
];
mesh.materialRefs = new AssetReferenceList("test1.material",
{ ref : "test2.material", "OptionalType" },
new AssetReference("test3.material", "OptionalType")
);
placeable.parentRef = "EntityName";
placeable.parentRef = 150;
placeable.parentRef = { ref : "EntityName" };
placeable.parentRef = { ref : 150 };
placeable.parentRef = new EntityReference("EntityName");
placeable.parentRef = new EntityReference(150);
var otherEnt = scene.EntityByName("EntityName");
placeable.parentRef = otherEnt;
placeable.parentRef = new EntityReference(otherEnt);
placeable.parentRef = null; // Clears ref
placeable.parentRef = undefined; // Clears ref
Let me know if there is a combo missing that you might want to be using or there are bugs in these ones. The DynamicComponent.js has now tests for all these cases and can be ran via --jsplugin jsmodules/Tests/Api/Scene/DynamicComponent.js
once merged to core.
Great!
Trying to set EntityReference by code but it doesn't do anything.
Example:
Console log: ents: racketRef: [object Object] racketRef.ref: Entity "racket" (ID: 16) 2 racketRef: [object Object] 2 racketRef.ref: <-- empty ref. should be "Entity "racket" (ID: 16)