I have recently taken an interest into unity, and as I guide a chose a playlist from youtube. I have installed the
Unity 5.6.4
16 Oct, 2017
version as well.
Now, I encounter an error when I try to add a script to an object.
In the tutorial:
here
, this happens from 11:40 to 13:40.
Basically, as a summary, he is writing a script in js and then attaches it to an object. Now, I have followed the exact steps as him, but it does not work for me.
I write the same script as him, in JS:
then add the script to the object. But then, on the object, I should get a target option, like he does:
However, I don't get this option on my object:
The error I get in the console is this:
Assets/Scripts/PickUp.js(1,386): BCE0044: unexpected char: 0xFEFF.
And this is the actual script:
var target : Transform;
function Update () { }
function OnMouseDown ()
{
this.transform.position = target.position;
this.transform.parent = GameObject.Find("FPSController").transform;
this.transform.parent = GameObject.Find("FirstPersonCharacter").transform;
}
function OnMouseUp ()
{
this.transform.parent = GameObject.Find ("FPSController").transform;
this.transform.parent = null;
}
Now, I've heard that it is not the most efficient, but at this point, I don't really care about that, I just want it to work.
Try to save your script using UTF8 - no BOM (ByteOrderMark). If that does not help, save as Ansi and try that - or read up what unity wants :)
Unity3d Issue Tracker: textassets-encoding-prefab-with-utf8-bom-encryption-is-corrupted it might be related.
This UTF-8 as default in Unity3D new script? was not solved unfortunately.
Related
i'm trying to make a web aplication than can read text automatically,i have this code:
function hablalo()
{
var palabra = new SpeechSynthesisUtterance('Casilla 6 turno E18');
palabra.lang = "es"
speechSynthesis.speak(palabra);
}
$('#perez').trigger($.Event( "click", { originalEvent: true } ));
and so i have a button with the event that call hablalo.
The problem is that when i try to make this, the result is:
(index):20 [Deprecation] speechSynthesis.speak() without user activation is no longer allowed since M71, around December 2018. See https://www.chromestatus.com/feature/5687444770914304 for more details
I would like a way to simulate a click in chrome or another way to make tts, thanks you. :)
--EDITED
If you know a library that i can use for autoplay tts at load of a webpage, is fine
So i solved my problem with this, summary i modify the laucher-flags of chrome in the client's pc adding --autoplay-policy=no-user-gesture-required at the end of route in propertiesof the launcher.
It seems like is imposible to make from code, but this solution is a resignation way.
I am currently working on a project where we need to generate some SVG based on some input data. Currently all this SVG generation is implemented in javascript using the d3 library. Note that my goal is to be able to reuse this logic and not implement it all over.
My problem is that I would like to be able to call this javascript from C#.
I have tried using PhantomJS and I am able to generate the SVG but I am not satisfied because
Each time I want to call the javascript it starts a new process and I
have noticed that it uses a lot of memory (In my case I saw 100 mb
which is too much in my case)
It seems a little unstable. I have
had some cases where the process just hangs
Development (On the javascript side) is pretty frustrating because it is hard to debug
Because I was not satisfied with PhantomJS I have also tried using jint and this seems really nice to work with. Unfortunately I haven't quite managed to get a working example up and running. Currently I am using AngleSharp to supply the DOM so that D3 has a place to write its data. This gives me the following example:
static void TestJint()
{
//We require a custom configuration with JavaScript and CSS
var config = Configuration.Default.WithJavaScript().WithCss();
//Let's create a new parser using this configuration
var parser = new HtmlParser(config);
//This is our sample source, we will do some DOM manipulation
var source = "<!doctype html> <html><head></head> <body> </body></html>";
var document = parser.Parse(source);
var jintEngine = new Engine();
jintEngine.SetValue("document", document.Implementation);
jintEngine = jintEngine.Execute(File.ReadAllText("d3.min.js"));
jintEngine = jintEngine.Execute("function testFunc() { d3.select(\"body\").append(\"span\").text(\"Hello, world!\"); return 42;}");
var res = jintEngine.Invoke("testFunc").ToObject();
}
The problem is that the line var res = jintEngine.Invoke("testFunc").ToObject(); throws an exception.
Exception screenshot
If I try replacing the line
jintEngine = jintEngine.Execute("function testFunc() { d3.select(\"body\").append(\"span\").text(\"Hello, world!\"); return 42;}");
with
jintEngine = jintEngine.Execute("function testFunc() { d3.select(\"body\"); return 42;}");
then the function is able to run without any exceptions. By playing a little with the logic I have concluded that it is the .append(\"span\") that causes the exception.
I am a little stuck so I was hoping that someone might have an idea that could point me in the right direction.
I have figured out the problems.
1) The document returned by parser.Parse(source); does not implement the function createElementNS which d3 uses. I solved this by using a wrapper that delegates the call.
2) d3 uses the variable ownerDocument which I havn't set. So I also had to add the following
jintEngine.SetValue("ownerDocument", new MyDocumentWrapper(document));
Note that this doesn't make the entire d3 library work. I have also noticed some problems with d3.geopath() but with these fixes I am able to execute my initial example.
Having lots of problems getting my sounds to play in a Flash-based Canvas project. I'm using the base example here (http://createjs.com/Docs/SoundJS/classes/Sound.html) in order work and all I get is a black screen and the following errors:
SyntaxError: missing ) after argument list
Which in my JS file is the following:
createjs.Sound.on("fileload", createjs.proxy(this.loadHandler, (this));
So I add the extra ) but now another error:
TypeError: createjs.Sound is undefined
Which is this:
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.FlashAudioPlugin]);
What's going on here? Why can't I just get this to play?
Here's the complete code:
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.FlashAudioPlugin]);
createjs.Sound.alternateExtensions = ["mp3"];
createjs.Sound.on("fileload", createjs.proxy(this.loadHandler, (this)));
createjs.Sound.registerSound("sounds/LaGrange.mp3", "sound");
function loadHandler(event) {
// This is fired for each sound that is registered.
var instance = createjs.Sound.play("sound"); // play using id. Could also use full source path or event.src.
instance.on("complete", createjs.proxy(this.handleComplete, this));
instance.volume = 0.5;
}
Well that's embarrassing. The example does have 2 errors. The first is the missing ")", which you caught and corrected. The second is that the FlashAudioPlugin is not completely setup. You need to add this line to set the path to the FlashAudioPlugin.swf before you register the plugins:
createjs.FlashAudioPlugin.swfPath = "../src/soundjs/flashaudio";
Thanks for catching this. I've pushed up a fixed version of this to github. Also, all the of the demos are well tested if you want more working examples to test from.
Hope that helps.
If you are testing locally (ie, not on a webserver - remote or local), then WebAudio can not play, since it uses XHR to load it, which does not work cross-domain (using file:/// is considered unsafe as well)
Change it to only use HTMLAudio when testing, and it should work.
Just getting started with Raphael.
Now I'm finding that paper.remove() is generating a script error:
"SCRIPT5009: 'removed' is undefined
Is this a script bug?
My variable paper is initialized thus:
var paper = new Raphael(document.getElementById('canvas_container'), 500, 500);
My HTML body has:
<div id="canvas_container"></div>
This is more info --
I am using Raphael 2.0 which I just downloaded again. Running IE9. Following is the Raphael JS function that is highlighted as the problem:
R.prototype.remove = function () {
eve("remove", this);
this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
for (var i in this) {
this[i] = removed(i);
}
};
the line ... removed(i) is highlighted --> SCRIPT5009: 'removed' is undefined
BTW I am new to this forum. Is there a way to respond to a thread other than "Answer Your Question"?
I've run across this a couple of times. The line 4443 method as suggested by sudoko-san does work in browsers but not backwards compatible with IE-7 & 8 (the whole point of using raphael).
Another work around is to implement the following code in your javascript:
try{
paper.remove();
}
catch (error) {
// this catches the error and allows you to proceed along nicely
}
That's it!
I don't know if you've supplied enough information to answer this question.
What version of Raphael are you using?
On what browser?
Is it being loaded up correctly - can you create any Raphael objects?
If all you're doing is deleting the paper, see the fiddle below.
JSFiddle
It seems to work fine for me with Raphael 1.5.2
Hope that helps (even slightly).
I use a Joomla! plugin that takes advantage of the DHTMLxGrid library, particularly version 1.5. I have problem when opening the page that uses this DHTMLx Grid functionality, everything works fine with Firefox, however, when I open the page in Chrome (7 and 8) the browser hits an exception on line 60 of the dhtmlxgrid.js file, triggered by the initialization of the grid. I have included a few lines of code, I know this is very limited data, but this is what I was able to to put here as a summary. I hope someone encountered a similar problem. I have limited knowledge of JS, so any help is greatly appreciated.
If you need more specifics, let me know and I will try to include more data.
Thanks!
The php file:
function gridInit(){
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("http://mydomain.com//administrator/components/com_com/images/dhtmlxGrid/");
mygrid.setHeader("ID,Start Period,End Period,Price (USD)");
mygrid.setInitWidths("50,120,120,80");
mygrid.setColAlign("center,center,center,center");
mygrid.setColTypes("dyn,dhxCalendarA,dhxCalendarA,edn");
mygrid.setDateFormat("%d/%m/%Y");
mygrid.setColSorting("int,date,date,int");
mygrid.init(); //...hits exception at this point
//...
}
The js file:
//dhtmlxgrid.js...
this.hdr = document.createElement("TABLE");
this.hdr.style.border="1px solid gray";
this.hdr.cellSpacing = 0;
this.hdr.cellPadding = 0;
if ((!_isOpera)||(_OperaRv>=8.5))
this.hdr.style.tableLayout = "fixed";
this.hdr.className = "c_hdr".substr(2);
this.hdr.width = "100%";
//...
var hdrRow = this.hdr.insertRow(_isKHTML?2:1); //dhtmlxgrid.js:60 Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1
//...
The error means an index is negative or too large. The line the error happens on is adding a row to a table, but there is a test for _isKHTML... I assume that is testing for konqueror, which was the progenitor of WebKit which Chrome is based on. Anyhow, try taking out that test and doing this instead:
var hdrRow = this.hdr.insertRow(1);
If that resolves the problem then the browser sniffing being used there is at fault, but if you don't have to support Linux running KDE then you should be fine without it.