Script can't be added to

but i still have the problem with the Math.random() used. Is there a way to get the correct unity function?

by user 945986115150696489

Ah you mean because your default values aren’t correctly exported?
You can also use // @nonSerialized on those fields and outside the CODEGEN_END put their declarations manually

Like this:

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

#pragma warning disable

namespace Needle.Typescript.GeneratedComponents
{
    public partial class FlockUnit : UnityEngine.MonoBehaviour
    {    
        // ... all auto generated code
    }
}

// NEEDLE_CODEGEN_END

namespace Needle.Typescript.GeneratedComponents
{
    public partial class FlockUnit : UnityEngine.MonoBehaviour
    {    
        // The "velocity" field is marked as //@nonSerialized in TypeScript so it is not automatically added in the generated code above
        public UnityEngine.Vector3 @velocity = new UnityEngine.Vector3(UnityEngine.Random.Range(-0.5f, 0.5f) * 2, UnityEngine.Random.Range(-0.5f, 0.5f) * 2, UnityEngine.Random.Range(-0.5f, 0.5f) * 2);
    }
}