imagicbell / ublockly

reimplementation of google blockly for Unity
http://imagicbell.github.io/unity/2017/10/11/blockly-one.html
Apache License 2.0
138 stars 52 forks source link

Block parameters doubts inputsInline, extensions, mutator #10

Closed JoeWar99 closed 3 years ago

JoeWar99 commented 3 years ago

Hi there we are having some doubts about the use of the following JSON block definition parameters:

Also, we are creating a wiki page for our project about your library if you want you can check it and see what you think so far and if it may be useful for you.

https://hackmd.io/@beBvDP44ShyK5VorFbhGcw/H1Qbb1HBu

imagicbell commented 3 years ago

Woo! I really appreciate your job. Well done! The wiki is more in detailed than mine. It appears that you have dived in deep in this library 👍 Regarding to your doubts

  1. inputsInLine: it's originally in google blockly. It decides whether the layout of the inputs in a block is horizontal or vertical. However, I didn't implement it, although I intended to... You can remove it currently. Sorry for that. It is useful. I have implemented this feature. Sorry that I have forgotten, since it was 3 years ago... It forces the block inputs to display horizontally (defaults vertically). Check the logic in method GetInputsInline() in Block.cs. If you remove this parameter, and rebuild the block prefabs(don't forget this, or nothing will change), you will see the difference.

  2. Extensions: it also can be removed. Originally from google blockly. Not used here.

  3. Mutator: This can't be removed. It is a feature. It means the block can be mutated based on the parameters you set. There is a settings icon on the topleft corner of the block view if this is a block with mutator. Please see block controls_if in 'logic.json'. It means this block can be mutated based on parameters, like the count of else if, whether there is else. As you know, if else block can have whatever many else if. Also there some mutators in 'procedures.json'. You can try them in demo. I have a doc here. But it is Chinese, I'll give a detailed English version in the future. Sorry again :)

The wiki is pretty detailed. Just one little thing. I have updated the settings of I18n Files in 'BlockResSettings.asset' to enable selecting current active language. If you have pulled the code, you can update the wiki as well. Thanks again for your work. I'll improve my doc, too :)

JoeWar99 commented 3 years ago

Thanks so much, yeah the wiki is still in progress but if you want after its done I can give you access and you can pick whatever you want from there. Also, just one little question also appeared. Does the align parameter of an arg do anything? We tried changing it and it didn't have any action.

imagicbell commented 3 years ago

There is an error in my last comment, please check. It's about the parameter inputsInLine.

The align parameter is useful. See the colour_rgb block in color.json. The three input are aligned right. The logic is: If any input of the block defines align: right, all the inputs will align right to avoid unpleasant UI. So if you remove all the align: right in the inputs of colour_rgb block, and rebuild the block prefabs (don't forget this, or nothing will change), you will see the difference.

I would be very glad for your contributions to the doc. I'd like to include you guys in my Contributors.

JoeWar99 commented 3 years ago

Thanks :) , we could do that after we finish the wiki which should be done by next week. Also we are having to implement the ublock library with states so that it can be part of a game and there are some issues that keep popping up in terms of functionality, would it be possible for us to speak by discord or skype with you sometime.

imagicbell commented 3 years ago

Sure, we could arrange in advance by email. However, hope the jet lag won't be too bother. I'm in +8:00

toamig commented 3 years ago

Hello there, i'm with him, would you mind meeting wednsday or early thursday? Just tell us an hour and we'll confirm with you. My email is carlosmiguelvieira@hotmail.com and discord nickname Toamig#9884

toamig commented 3 years ago

Or either if you could explain us how to properly reset the workspace, it would be awesome! We try to reset it when we change interfaces, but it turns out to be null before we even dispose it, weird interaction.

imagicbell commented 3 years ago

You mean you intend to reset the workspace not only the blocks part, but also the left toolbox side?

imagicbell commented 3 years ago

There are 2 ways.

  1. Brutal

    BlocklyUI.DestroyWorkspace();
    GameObject.Instantiate(workspacePrefab, GameObject.Find("Canvas").transform);

    This destroys the Workspace gameobject entirely and then re-create a new one. In your case, you can add some logic in ToolboxConfig.Load() to customize what to show. This also reset the logical workspace, not only the UI. Just everything.

  2. Reset block views and toolbox respectively.

    • Clean blocks
      BlocklyUI.WorkspaceView.CleanViews();
    • Reset Toolbox
      BlocklyUI.WorkspaceView.Toolbox.Clean();
      BlocklyUI.WorkspaceView.Toolbox.Init(BlocklyUI.WorkspaceView.Workspace, ToolboxConfig.Load());

      I added a new method Clean in BaseToolbox.cs for this. Please check. Or if you want it more straightforward in your application, you can follow this to implement your own reset logic.

toamig commented 3 years ago

Thank you so much, this worked perfectly for resetting the workspace.

Btw, did you notice there is a bug sometimes on deleting a huge complex block where small leaf blocks won't get erased and then stay on the workspace although they don't exist anymore?

Imgur

Error when trying to move these blocks

Imgur

imagicbell commented 3 years ago

Sorry for this big bug. I have fixed it in this commit.

toamig commented 3 years ago

I think you can close this issue, thanks for the help!