#C-sharp component not being generated

1 messages · Page 1 of 1 (latest)

raven cedar
#

I've tried adding the Rotate.ts script as per the documentation but I am not getting any Monobehavior script in Needle/Components.codegen

I get two Unity console messages after saving my Rotate.ts script:

/Assets/../Library/Needle/CodeGen/Types.json
SourceFiles: -1 

Run codegen for Rotate.ts at ...../Needle/CollaborativeSandbox/src/scripts/Rotate.ts```

I've tried enabling/disabling the Code Generator Component in Unity
mystic axle
#

Are you on windows? What is your project path? The run codegen path in the log looks suspicious (starting with ...../Needle)

raven cedar
#

Hi. I'm on Mac. I've just edited out the rest of the file path that has my name and other bits in it

mystic axle
#

Ah I see. Does the path look correct? Maybe replace it with xxxx next time 🙂 makes it less confusing^^

But SourceFiles: -1 also looks wrong

#

Does the log say anything? The console log should also contain a path where the compiler produces a log file - maybe it has some info on why it didnt output a script

raven cedar
mystic axle
#

I've also asked for the path because we sometimes had issues with special characters in paths (e.g. paths containing ( )

raven cedar
#

Ok, let me just copy and paste the full log

mystic axle
#

Could you also try creating a npmdef and copy paste your script there?

raven cedar
# mystic axle Does the log say anything? The console log should also contain a path where the ...
SourceFiles: -1 
Time since last update: 121.095099
UnityEngine.Debug:Log (object)
Needle.Engine.Codegen.TypesGenerator:GenerateTypesIfNecessary () (at Library/PackageCache/[email protected]/Core/Runtime/Codegen/TypesGenerator.cs:60)
Needle.Engine.Codegen.ComponentGeneratorRunner/<Run>d__0:MoveNext () (at Library/PackageCache/[email protected]/Core/Runtime/Codegen/ComponentGeneratorRunner.cs:35)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>:Start<Needle.Engine.Codegen.ComponentGeneratorRunner/<Run>d__0> (Needle.Engine.Codegen.ComponentGeneratorRunner/<Run>d__0&)
Needle.Engine.Codegen.ComponentGeneratorRunner:Run (string,string,string,string)
Needle.Engine.Codegen.CodeWatcher/<ProcessChangedFiles>d__29:MoveNext () (at Library/PackageCache/[email protected]/Core/Runtime/Codegen/CodeWatcher.cs:160)
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start<Needle.Engine.Codegen.CodeWatcher/<ProcessChangedFiles>d__29> (Needle.Engine.Codegen.CodeWatcher/<ProcessChangedFiles>d__29&)
Needle.Engine.Codegen.CodeWatcher:ProcessChangedFiles ()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:356)
raven cedar
# raven cedar ```Generate codegen types: /Users/durril/Documents/Unity Projects/Needle Engine ...

Command: node component-compiler.js "/Users/durril/Documents/Unity Projects/Needle Engine Test/Assets/Needle/Components.codegen" "/Users/durril/Documents/Unity Projects/Needle Engine Test/Needle/CollaborativeSandbox/src/scripts/Rotate.ts" in /Users/durril/Documents/Unity Projects/Needle Engine Test/Library/PackageCache/[email protected]/package~/node_modules/@needle-tools/needle-component-compiler/src

Log at: /Users/durril/Documents/Unity Projects/Needle Engine Test/Assets/../Temp/component-compiler.log
UnityEngine.Debug:Log (object)
Needle.Engine.Codegen.ComponentGeneratorRunner/<Run>d__0:MoveNext () (at Library/PackageCache/[email protected]/Core/Runtime/Codegen/ComponentGeneratorRunner.cs:39)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>:Start<Needle.Engine.Codegen.ComponentGeneratorRunner/<Run>d__0> (Needle.Engine.Codegen.ComponentGeneratorRunner/<Run>d__0&)
Needle.Engine.Codegen.ComponentGeneratorRunner:Run (string,string,string,string)
Needle.Engine.Codegen.CodeWatcher/<ProcessChangedFiles>d__29:MoveNext () (at Library/PackageCache/[email protected]/Core/Runtime/Codegen/CodeWatcher.cs:160)
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start<Needle.Engine.Codegen.CodeWatcher/<ProcessChangedFiles>d__29> (Needle.Engine.Codegen.CodeWatcher/<ProcessChangedFiles>d__29&)
Needle.Engine.Codegen.CodeWatcher:ProcessChangedFiles ()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:356)
mystic axle
#

That's the path I meant /Users/xxxxx/Documents/Unity Projects/Needle Engine Test/Assets/../Temp/component-compiler.log

raven cedar
#

No file named component-compiler.log

mystic axle
#

Can you try opening a terminal and run this command:

node component-compiler.js "/Users/durril/Documents/Unity Projects/Needle Engine Test/Assets/Needle/Components.codegen" "/Users/durril/Documents/Unity Projects/Needle Engine Test/Needle/CollaborativeSandbox/src/scripts/Rotate.ts"
in this directory:
/Users/durril/Documents/Unity Projects/Needle Engine Test/Library/PackageCache/[email protected]/package~/node_modules/@needle-tools/needle-component-compiler/src

raven cedar
#

Ok I got this back ``` SourceFile
ImportDeclaration
ImportClause
NamedImports
ImportSpecifier
Identifier
ImportSpecifier
Identifier
StringLiteral
ClassDeclaration
Found class: Rotate
NAMESPACE Needle.Typescript.GeneratedComponents
Rotate inherits UnityEngine.MonoBehaviour
ExportKeyword
Identifier
HeritageClause
ExpressionWithTypeArguments
Identifier
PropertyDeclaration
Found variable @serializable()
speed : number = 1;
Variable: speed
Child: NumberKeyword → float
EMIT member: "float" @speed = 1f Last type found: null
Decorator
CallExpression
Identifier
Identifier
NumberKeyword
FirstLiteralToken
MethodDeclaration
Identifier
Block
ExpressionStatement
CallExpression
PropertyAccessExpression
Identifier
Identifier
ThisKeyword
MethodDeclaration
Identifier
Block
ExpressionStatement
CallExpression
PropertyAccessExpression
PropertyAccessExpression
ThisKeyword
Identifier
Identifier
BinaryExpression
PropertyAccessExpression
PropertyAccessExpression
PropertyAccessExpression
ThisKeyword
Identifier
Identifier
Identifier
AsteriskToken
PropertyAccessExpression
ThisKeyword
Identifier
Write to /Users/durril/Documents/Unity Projects/Needle Engine Test/Assets/Needle/Components.codegen/Rotate.cs
EndOfFileToken

mystic axle
#

Did it also write the file?

raven cedar
#

It did!

mystic axle
#

Ok great - so something is not working with sending the command to the compiler 🤔 maybe

#

if you edit the ts file and Unity tried to re-generate it - does it work? Or not?

#

E.g. add a new field or remove it 🙂

#

or rename the class

raven cedar
#

Yes that works

#

I've also tried adding a new script but it doesn't generate

mystic axle
#

🤔 ok that's strange. did you also try with the npmdef?

raven cedar
raven cedar
mystic axle
raven cedar
mystic axle
#

Ok - of course the classname shouldnt be the same 😅

raven cedar
#

No luck with using npmdef :I

mystic axle
#

Ok good 🙂

#

I mean then its at least consistent 🙂

raven cedar
#

Oh ok - fair enough

reef charm
#

also have this issue on Windows and Mac, what can i do?

#

@mystic axle i tried your command and after this c# script generated
but new scripts dont generate

mystic axle
#

What is the path of your project? Can you share the compiler log file too? You can also use Help/Needle Engine/Collect logs and PM me the zip

mystic axle
#

Which node version are you using?

reef charm
#

After trying to save this logs

Generate codegen types: /Users/ivan/SirenaSnake/Assets/../Library/Needle/CodeGen/Types.json
SourceFiles: 1800

Run codegen for Rotate.ts at /Users/ivan/SirenaSnake/Needle/Main/src/scripts/Rotate.ts
Command: node component-compiler.js "/Users/ivan/SirenaSnake/Assets/Needle/Components.codegen" "/Users/ivan/SirenaSnake/Needle/Main/src/scripts/Rotate.ts" in /Users/ivan/SirenaSnake/Library/PackageCache/[email protected]/package~/node_modules/@needle-tools/needle-component-compiler/src

reef charm
#

also i switch from 2022 version to 2021.3 as recommend on requirements

reef charm
#

also wanted to mention that
my rotate.cs

// NEEDLE_CODEGEN_START
// auto generated code - do not edit directly

#pragma warning disable

namespace Needle.Typescript.GeneratedComponents
{
    public partial class Rotate : UnityEngine.MonoBehaviour
    {
        public float @speed = 1f;
        public float @money = 3f;
        public void start(){}
        public void update(){}
    }
}

// NEEDLE_CODEGEN_END

when rotate.ts is

import { Behaviour, serializable } from "@needle-tools/engine";

export class Rotate extends Behaviour
{
    @serializable()
    speed : number = 1;
    
    money: number = 3;

    start(){
        // logging this is useful for debugging in the browser. 
        // You can open the developer console (F12) to see what data your component contains
        console.log(this);
    }

    // update will be called every frame
    update(){
        this.gameObject.rotateY(this.context.time.deltaTime * 1);
    }
}

it's quite strange that update is empty

#

it's after when i run command manually from terminal

#

also thanks for needle
it's quite brilliant idea to bring unity to three js because wasm and unity webgl too slow

but i can't use engine at all because custom scripting doesnt work🥲

mystic axle
#

It does work, you can use needle engine and the exporter, just auto compiling seems to have an issue from unity for some of you. I tried this on osx after it was reported but couldnt reproduce (the compiler worked as expected)

Im currently on holiday and will be back on the 30th to try to figure out why. You can manually create a c# component or invoke the script command manually that is logged in the console. Exporting components does still work.

Also all methods in csharp will always be empty because we don't build the full csharp code, only components to hold the data for you to setup in unity and export (you can still implement them in c# if you want to of course)

#

You can read about it at https://docs.needle.tools/scripting

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally. Needle Exporter for Unity bridges the Unity Editor and the web runtime. It helps you to export your assets, animations, lightmaps and so on to the web. It is...

reef charm
#

oh, i see
everything working, okey
it's quite interesting why auto exporter doenst work in mac os and windows (two different machines)
thanks for reply, now i can use command btw

mystic axle
#

By auto exporter you mean the compilation of js to csharp mock right?

mystic axle
reef charm
#

yeah, i can generate c# files only with compile command, auto save doesnt work

mystic axle
#

Hey guys, could you try updating to the latest release and then try running the same command using the command tester window I added? You can open it via this menu item

#

and then enter the command you run manually with the correct paths like this and tell me what it says 🙂 (you can try both Run in Unity and Run External)

#

You can also try enabling "Debug" on the component and then re-save one of the scripts

ashen widget
#

I'm also having problems with the generator. I tried running the command in the command tester and I got zsh:1: command not found: node. Could it be related to the node path issue reported here? #📍-needle-engine message

mystic axle
#

Yes that would be that issue. But does generating projects work? Do you use nvm?

mystic axle
#

@reef charm any chance you could try the above too once more? Im currently trying to reproduce / figure out why its not working for you guys.

reef charm
#

yeah, i will try later today, thanks

mystic axle
#

thank you

#

@tulip plume sorry to ping you - you also had problems with the compiler not working or was it just the error with the wrong path check that caused problems?

#

I just realized that internally it doesnt handle "node" commands the same way it does "npm" commands, so maybe that is the problem here

tulip plume
#

Hi @mystic axle ... I'm fairly certain that it was just the error with the wrong path check that was the issue, in my case.

Just shout if there's anything you'd like me to specifically check out and/or test 👍

mystic axle
tulip plume
#

I'll give that a go right now, and let you know asap 👍

Re: node installation... I adhered to the instructions provided via the 'Get Started' page. I can't remember precisely what advice was given there and I'm afraid I can't copy and paste the walkthrough as I've just noticed that the 'see details' link I originally followed no longer works.

mystic axle
tulip plume
#

Cool. I downloaded and installed MacOS Universal 16.17.0

reef charm
mystic axle
#

2.55.1 is latest 🙂

tulip plume
#

Hi again @mystic axle ... I've just set up a brand new test collab sandbox from scratch and run the command tester, which confirmed that I'm running node v 16.17.0

mystic axle
#

Ok, thanks for testing!

mystic axle
#

How did you install node? Nvm or also using the installer?

#

What does which node print when you run it in the terminal?

#

I might have a fix - will publish in a second

reef charm
#

/Users/ivan/.nvm/versions/node/v16.14.0/bin/node

#

i have installed node before trying needle, because using it for vue, vite and other js projects

mystic axle
#

Ah nvm ok, thanks.

#

Could you update to 2.55.2-pre and let me know if that helps?

reef charm
#

oh, nice! everything is working now

#

auto saving works perfectly, thanks for helping

mystic axle
#

Nice!

#

Thanks for testing!

ashen widget
mystic axle
#

The previous path bug should also be fixed 🙂 but thanks, good to hear

eternal beacon
#

I ran in to this same issue on exporter version 2.58.1-pre. Fix in my case was to update my project path to include no spaces.

mystic axle
#

Thats interesting! The paths are all wrapped with " for that reason. Are you on windows?

#

Could you pm me the previous path that didnt work?

eternal beacon
#

I'm on MacOS

mystic axle