Script Gen error

(Alien) #1

I tried to export the blox3 to c# scripts, but get this error.

The load bar for the script-gen seems stuck at
loading definitions

Error in Console:
ArgumentException: You can only call GUI functions from inside OnGUI.
UnityEngine.GUIUtility.CheckOnGUI () (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUIUtility.cs:250)
UnityEngine.GUI.get_skin () (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUI.cs:53)
BloxEditor.BloxEdGUI.Create () (at D:/DevUnity/_SOURCE/Blox/BloxEditor/BloxEdGUI.cs:323)
BloxEditor.BloxEdGUI.get_Instance () (at D:/DevUnity/_SOURCE/Blox/BloxEditor/BloxEdGUI.cs:306)
BloxEditor.BloxEd+d__36.MoveNext () (at D:/DevUnity/_SOURCE/Blox/BloxEditor/Blox/BloxEd.cs:329)
plyLibEditor.plyEdCoroutine.DoUpdate () (at D:/DevUnity/_SOURCE/plyLib/plyLibEditor/plyEdCoroutine.cs:60)
BloxEditor.BloxEd.DoUpdate () (at D:/DevUnity/_SOURCE/Blox/BloxEditor/Blox/BloxEd.cs:53)
BloxEditor.BloxScriptGenerator.GenerateAllScripts () (at D:/DevUnity/_SOURCE/Blox/BloxEditor/Blox/ScriptGen/BloxScriptGenerator.cs:91)
BloxEditor.BloxEdGlobal.Menu_ScriptGen_CompileAll () (at D:/DevUnity/_SOURCE/Blox/BloxEditor/BloxEdGlobal.cs:260)

(Alien) #2

ok i clicked on generate Scripts a couple more times and the error just went away, but it seems i get other errors while the script tries to export.

It seems maybe the comment blox is not supported in the export to scripts? i was hoping to be able to export while keeping all the comments, is this not possible? Can this be supported? i would like to comment my blox code and keep the comments when i export to C#.

  • i removed the comment blox and the errors went away, but being able to export the comment info would be super useful.

(Leslie Young) #3

Thanks. Will submit patch in 3.3.3 later today.

(Alien) #4


(Alien) #5

i finally got to ver3.3.4 and got everything working without errors. I’m now trying to export to Scripts, but get this error:
looks like 1 script is generated.

Side question: is there anyway to get the blox object updated with the actual blox name. for example _e5dfe78… is one of my blox scripts, either menuController or settingsController, but no idea which one. it would be nice if they could be renamed (either during export or when you actually rename them in blox), so the actual script name when exported is the same as your blox names (and not some big long _hex number). maybe to reduce the potential of name duplication, they could be “_menuController” for example, using the underscore?

anyway here is the error i get when trying to create the c# script.

(Leslie Young) #6

is there anyway to get the blox object updated with the actual blox name

I’ll look into adding an option.

anyway here is the error i get when trying to create the c# script.
looks like 1 script is generated.

Yes. Broken scripts are not saved so only the oe which was fine was “generated”.
But I can see how this is a bit of a problem when trying to find possible bugs in the script-gen since we now have nothing to look at and the error is too value in this case.

I’ll add an option to still save the broken script.

(Alien) #7

First, The option to use the blox name instead of the GUID works great and along with the notes in the console, really helps find the script and makes it easier to read in the generated code.
Second, The option to get the script to generate even in failure, really helped identify the problem(s), so the additional features are very useful.

I’m of course getting the error still, but in both cases below I’m just not sure if I’m doing it incorrectly (from a blox logic perspective), if it’s not supported or if maybe there is a bug…

Issue1: Upon script gen i get the same error as above “bloxContainer” issue.

in blox (menuController) I’m calling (trigger event) another blox event. as seen here:

here is the code that is causing the problem:

    // Event name: loadGameMenu
    public System.Collections.IEnumerator loadGameMenu(BloxEngine.BloxEventArg[] args)
        // Spin Cogs and initiate Sfx
        BloxEngine.BloxUtil.GetComponent <BloxEngine.BloxContainer>(b_audioPlayer_2924.GetGameObject()).bloxContainer.TriggerEvent("playCogs", 0F);
        BloxEngine.BloxUtil.GetComponent <BloxEngine.BloxContainer>(b_audioPlayer_2924.GetGameObject()).bloxContainer.TriggerEvent("playSoundFx", 0.2F);

Seems to be that by calling those events (methods), its failing or cant find them?

Issue2: the other problem is with the audio playoneshot.

code generating the error:

    // Event name: playSoundFx
    public void playSoundFx(BloxEngine.BloxEventArg[] args)
        b_audioPlayer_69d1.GetComponent <UnityEngine.AudioSource>().PlayOneShot(b_CogSfx_e59f.GetValue(), 0.5F);
        b_audioPlayer_69d1.GetComponent <UnityEngine.AudioSource>().PlayOneShot(b_SlideSfx_42df.GetValue(), 0.3F);


related errors in console:

Assets/projectData/Blox/scripts/menuController_1254.cs(180,99): error CS1503: Argument #1' cannot convertUnityEngine.Object’ expression to type `UnityEngine.AudioClip’

Assets/projectData/Blox/scripts/menuController_1254.cs(181,73): error CS1502: The best overloaded method match for `UnityEngine.AudioSource.PlayOneShot(UnityEngine.AudioClip, float)’ has some invalid arguments

any thoughts or input would be appreciated and thanks again for your help.

(Leslie Young) #8


Technically you can just do this since the Events are all in the same Blox.

But there is a bug in the trigger event block’s script-gen. Will be fixed in next update.


I’ll have to make some changes to the variable block’s script generator to resolve that.

(Alien) #9

Both scripts compiled successfully. No errors in the console.

So, now i drag and drop the script on to an object, and the only variables options are the Blox Container. I’m not sure what should be placed in there, since the intention would be to remove blox from this project once the scripts are good and scripts replace the blox container on each object…

One somewhat related question, there isn’t an easy “search and replace” way of swapping out the Blox Container on each object with the appropriate generated script would there?

code snip:

namespace BloxGenerated

public class settingsController_e5df : UnityEngine.MonoBehaviour
    public BloxEngine.BloxContainer bloxContainer;
    private BloxEngine.Variables.plyVar_Component b_sfxMasterVolSliderObject_f9be;
    private BloxEngine.Variables.plyVar_Float b_sfxMasterVolLevel_9cf1;
    private BloxEngine.Variables.plyVar_Component b_dropDownTextObject_8b9d;
    private BloxEngine.Variables.plyVar_String b_initRes_7518;
    private BloxEngine.Variables.plyVar_Component b_gfxQualSliderObject_3b97;
    private BloxEngine.Variables.plyVar_Int b_gfxQualityLevel_006c;
    private BloxEngine.Variables.plyVar_Component b_toggleTouchObject_cb57;
    private BloxEngine.Variables.plyVar_Component b_toggleFullScreenObject_0477;
    // Init

thanks again for your quick responses and as always, very much appreciated.

(Leslie Young) #10

since the intention would be to remove blox from this project once the scripts are good and scripts replace the blox container on each object…

no. You can not remove Blox from the project; even after script-gen. Blox is NOT a C# editor. The final build will always include the Blox DLL.

The Blox Container will remain on all objects since it is responsible for adding the the generated component (script) onto the object at runtime. At runtime the Container checks whether there is a valid generated script and uses that; else it falls back to the Blox Definition.

The variables are still accessed via Blox specific code; see for example the generated script code BloxEngine.Variables.plyVar_Component b_sfxMasterVolSliderObject_f9be; and the later Getvalue() type functions to follow on that variable. C# primitive/value types are not used for variables. For ecxample “float” will always be handled via plyVar_Float and not be converted to a float type in the generated script (except Event Variables where possible).

(Alien) #11

my use case:
For example, i wanted to publish some art assets on the unity store, an include a simple demo scene which has some script functionality from blox. The original intention was just to generate scripts, and publish to the store. which lets me add a little functionality / example scenes, instead of just the art assets themselves.

I guess this was my misunderstanding then. i don’t remember seeing this limitation anywhere in the documentation and was under the impression that if you can generate C# scripts, you wouldn’t need to include blox3. really whats the point of generating scripts if you still have to have your DLL included? Well i guess i can see how it could be a bit faster not having to decipher the blox during runtime… but still…
I believe Nottorus does this and it isn’t a C# editor either (at least not imo)… You should make this more clear in your docs or have some sort of disclaimer that you still need blox. I guess I’m somewhat frustrated. i really like blox and how it works over the node base approach and to be honest probably wont use this script-gen feature much, but really wanted to see this work…

(Leslie Young) #12

I did not initially plan to add script-gen to Blox but someone requested it and I had some free time. The benefit is that generated scripts can be faster to run than the Blox executing each Block in an Event.

Personally I will not be using script-gen for my own games since I feel the Blox runtime is fast enough. But it all depends on what your Events do and how complicated they are. I do not use Blox to create whole systems or heavy logic like a character controller. I use it to respond to events and trigger things in other systems provided by Blox, BGS, (or plugins once I have TBRPG done for example).

Nottorus say from the first line that it is for making and debugging C# scripts while I’ve always held that Blox is not an IDE or alternate way of writing C# code when someone asks about it. Script-gen is a minor feature to me and I even mention it as an afterthought in the description of the product.

It does what it say it do. It turns Blox Definitions into scripts. But if you use Blocks which makes calls into the Blox API then the script generator will generate scripts which makes those same calls into the API; and there are plenty such Blocks. Like calls to BloxUtil, triggering Events, the Variables system, and many others. So the runtime DLL which includes these is a must have.

(Alien) #13

thanks for the info. the frustration really stems from my misunderstanding.