-
-
Notifications
You must be signed in to change notification settings - Fork 57
Script entities #1320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: protocol_changes
Are you sure you want to change the base?
Script entities #1320
Conversation
Without looking at your current code: I would just like to avoid the relative mess we currently have with material entities. Those are extremely powerful, but also really clunky and manual in their use. |
I’d like to save that for another PR, but yeah that’s exactly the idea, to be able to treat them as components of their parent entity in the UI, regardless of this internal implementation I think we could do something similar for material entities to make them easier to use, so you can add them directly from the parent instead of having to switch between entities, but that’s all just UX on top |
I agree, great features to add to Create app... Add a Material Entities (from any entities) Why not add any type entities as a child? (just an idea, any thought?) also i was considering to add: |
for script entities, I think it would be good if on the script tab, all entities had a little list view of all the children script entities, with a button to take you to each of them and a button to add a new one. similarly for material entities, not sure where to put it, but a list of all children material entities, with buttons to go to them, and a button to add a new one yeah “add any entity type as a child” could also be useful! anything to save a few clicks. maybe a button next to parentID to go to the parent? “Copy color from Skybox” also sounds great 😁 |
Here how I would plan to make this in create app:
|
@AleziaKurdis that sounds great! I think the button next to parentID which takes you to the parent would also be really useful |
One thing that I think could be really useful, would be a field with named references to the entities that script will use. |
that’s a cool idea! you could use tags/names for this now but I see how that would be easier. maybe we can leave it for a separate PR? if people are happy with the general idea here, then this is ready for review/testing from my end |
A big problem with tags and names is that they don't work if you spawn several instances of a given prefab in a single world. A standarized way of spawning prefabs would be very important for ease of creation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good :)
I just tested it and entity server crashes very often with message:
Crash happens mostly on parenting script entity with a running script to another entity.
Backtrace doesn't seem helpful - seems like a freshly started thread:
I'm attaching backtrace for all other threads as text file, because it's big. |
I also see that there's only one script URL field there. Do these support client side scripts only? |
thank you for testing! I will take a look. it is currently just for client side scripts, in the future we could add a toggle for server vs. client |
cant wait till this is in interface it looks fun |
326980d
to
9eacc57
Compare
@ksuprynowicz crashes fixed and icons updated! |
adds a new Entity type, Script, with two properties:
scriptURL
andenabled
. like material entities, script entities apply to their parents. if no parentID is set (or enabled is false),scriptURL
won't run (but the existingscript
property, which applies to the entity itself, will).one advantage of this approach is that each script can have its own separate user data/parameters. this is implemented as a new entity script method,
updateUserData
, which is called when userData changesfor a demo, run this script: https://gist.github.com/HifiExperiments/9da7d78021c4d3b08c7ca72ed03d846d/raw/f2a1228e5584167b0f3bfcfa9e16f8268158fd28/ScriptEntitiesTest.js
it creates a box with two child script entities, one which modifies the box's position, and one which modifies its dimensions. the dimension one is disabled at the start, but if you enable it in create, you can see that both will change at the same time!
thank you to @AleziaKurdis for the great new icons