mixer / interactive-unity-plugin

Unity Plugin for Mixer Interactivity
MIT License
59 stars 23 forks source link

updateScenes doesn't seem to update anything? #117

Closed djarcas closed 5 years ago

djarcas commented 5 years ago

I'm using a fully dynamic scene and group system for per-user controls. Essentially UserID 123 will get a Group and a Scene of their own, and the code will be responsible for updating things.

Things are going ok, but updateScenes doesn't seem to do anything. I initially create a scene with a couple of buttons on it; when one of them is pressed, I then use updateScenes to remove those 2 button and create a new one. However, the response from the server seems to show that although the upgoing data is just fine, the response from the server appears to be the initial scene!

SendJsonString:[{"type":"method","id":6,"method":"createScenes","params":{"scenes":[{"sceneID":"DynamicSceneID66482112","controls":[{"controlID":"WelcomeButton_66482112","kind":"button","text":"Welcome MetalMercury215","cost":0,"progress":0.25,"disabled":false,"position":[{"width":24,"height":10,"size":"large","x":32,"y":-25},{"width":24,"height":10,"size":"medium","x":32,"y":-25}],"glow":{"value":{"color":"#f00","radius":10}}},{"controlID":"JoinButton_66482112","kind":"button","text":"Press to Join!","cost":0,"progress":0.25,"disabled":false,"position":[{"width":24,"height":10,"size":"large","x":32,"y":-15},{"width":24,"height":10,"size":"medium","x":32,"y":-15}],"glow":{"value":{"color":"#f00","radius":10}}}]}]}}]

So we create DynamicSceneID66482112 with 2 buttons - Join and Welcome.

After the button is pressed, I update the scene:

SendJsonString:[{"type":"method","id":10,"method":"updateScenes","params":{"scenes":[{"sceneID":"DynamicSceneID66482112","controls":[{"controlID":"DoNothingButton_66482112","kind":"button","text":"COMBAT IN PROGRESS MetalMercury215","cost":0,"progress":0.25,"disabled":false,"position":[{"width":24,"height":10,"size":"large","x":32,"y":-35},{"width":24,"height":10,"size":"medium","x":32,"y":-35}],"glow":{"value":{"color":"#f00","radius":10}}}]}]}}]

This has one button, called DoNothingButton.

However, the reply I get back shortly afterwards appears to be the first scene again!

{"id":10,"type":"reply","result":{"scenes":[{"sceneID":"DynamicSceneID66482112","etag":"","controls":[{"controlID":"WelcomeButton_66482112","kind":"button","text":"Welcome MetalMercury215","cost":0,"progress":0.25,"disabled":false,"position":[{"width":24,"height":10,"size":"large","x":32,"y":-25},{"width":24,"height":10,"size":"medium","x":32,"y":-25}],"glow":{"value":{"color":"#f00","radius":10}}},{"controlID":"JoinButton_66482112","kind":"button","text":"Press to Join!","cost":0,"progress":0.25,"disabled":false,"position":[{"width":24,"height":10,"size":"large","x":32,"y":-15},{"width":24,"height":10,"size":"medium","x":32,"y":-15}],"glow":{"value":{"color":"#f00","radius":10}}}],"groups":null,"meta":{}}]},"seq":19}

Any ideas?

payzer commented 5 years ago

@djarcas For updating controls, you're going to want to use the updateControls method. https://dev.mixer.com/guides/mixplay/protocol/specification#updatecontrols

djarcas commented 5 years ago

Uh, really? What does UpdateScenes do then? I have to pass up all the controls in the scene still, according to that demo?

payzer commented 5 years ago

Yea, from my understanding updateScenes updates scene properties and updateControls updates controls within a scene.

djarcas commented 5 years ago

Are the controls that exist within a scene not considered 'scene properties'? (I'm adding and removing buttons, not changing the text on existing buttons)

payzer commented 5 years ago

I re-created your scenario this morning and from investigating, it looks like no.

djarcas commented 5 years ago

I'll try calling updateControls and see what happens. It's a little odd that CreateScene, UpdateScene and UpdateControls are interchangeable barring the Method name!

payzer commented 5 years ago

Yea it's a little strange. Threw me off myself. If you run into problems, let me know. I've got it working on my machine so I can help if you have issues doing it with updateControls.

rasterknight commented 5 years ago

Thanks for this discussion, as I'm myself digging into custom ParticipantViews with CDK/HTML I was thinking on how to work on the controls. I was thinking of doing all the button stuff on the participant side (in HTML templates) and only have a table of controls IDs so that the giveInput message would go from Participant to Client. Anyway this UpdaceControls thing might help.

payzer commented 5 years ago

Cool. I'm also doing a full CDK/HTML thing. Once you go that route it actually easier to just use sendMessage and broadcastEvent for me at least. And then I handle all the per-user view logic in JavaScript and HTML. But if you want to avoid the CDK, then this is the only way to do it. With the CDK you have a lot more options.

I realized we resolved the issue, so I'll close it now. Thank you all for the discussion!

djarcas commented 5 years ago

So, I've had time to look at this again, and it still doesn't work - as I said initially, I am changing the participant's scene dynamically, so the old buttons aren't there, and the new buttons appear. But using updateControls just means that I get the error "unknown control id specified"

Which... makes sense? Cuz the old control isn't there. And I just added a new control. How do I achieve modifications of existing scenes if updateControls only changes existing controls, and if updateScenes isn't suitable?