Saturday, July 23, 2022
HomeGame DevelopmentMethods to use net employee in typescript cc 3.5.1? - Cocos Creator

Methods to use net employee in typescript cc 3.5.1? – Cocos Creator


Hello everybody, I’m having drawback utilizing net employee in cocos.
I’ve file a.ts and file employee.ts. How am i able to import file a.ts into employee.ts ? I attempt to use importScripts(a.js) however it’s not work as a result of importScripts just isn’t outlined.


I may be off with what you’re asking however if you wish to import one other script I’ve completed it like this.

import { yourscript } from './a';

Then you possibly can name like:

yourscript.someVariable

I’ve file most important.ts like this

import  MyWorker from `../MyWorker'
 const code = MyWorker.toString();
    const blob = new Blob([`(${code})()`]);
    const employee = new Employee(URL.createObjectURL(blob));

file MyWorker like this

import AnotherFile from '.../AnotherFile';

export default () => {
  console.log(take a look at, AnotherFile); // error right here
};

I’m undecided why your importing the script after which changing to a string? Is the response from the script solely going to be as a string? Even then I’d anticipate a perform would should be referred to as from the myWorker script, then convert the response to a string?

I.e

Const code = myWorker.myFunction().toString();

That is presuming you’ve extra to your script then outputting the console.log. which if that’s your present purpose then console log received’t work as you’re changing to a string (or atleast I wouldn’t suppose in order it’s now not an object). I’m guessing there’s extra to the myWorker script as I might presume in order you possibly can’t convert a console log to a blob both.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments